Skip to content

Commit

Permalink
Fix code by psr
Browse files Browse the repository at this point in the history
  • Loading branch information
propan13 committed Jun 4, 2024
1 parent dbe4e7d commit 40a75b4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
2 changes: 0 additions & 2 deletions code/public/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@
} catch (\Exception $e) {
echo $e->getMessage();
}


2 changes: 1 addition & 1 deletion code/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function run(): void
$router = new Router();
$router->dispatch($command);
}
}
}
2 changes: 1 addition & 1 deletion code/src/Chat/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public function launch(): Generator
yield 'Received ' . $this->read() . PHP_EOL;
}
}
}
}
1 change: 0 additions & 1 deletion code/src/Chat/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class Server extends Socket
{

public function init(): void
{
$this->create();
Expand Down
9 changes: 4 additions & 5 deletions code/src/Chat/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
abstract class Socket
{
private \Socket $socket;

abstract function init(): void;

abstract function launch(): Generator;
abstract public function init(): void;
abstract public function launch(): Generator;

public function __construct()
{
Expand Down Expand Up @@ -49,7 +48,7 @@ public function bind(bool $isNew = false): void

public function listen(): void
{
$listen = socket_listen($this->socket,1);
$listen = socket_listen($this->socket, 1);
if ($listen === false) {
throw new Exception('Could not listen on socket');
}
Expand Down Expand Up @@ -93,4 +92,4 @@ public function read(): false|string
{
return socket_read($this->socket, $_ENV['CHAT_SOCKET_LENGTH']);
}
}
}
2 changes: 1 addition & 1 deletion code/src/Router/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function getCommandName(): string
{
return $this->commandName;
}
}
}
5 changes: 3 additions & 2 deletions code/src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function __construct()
public function dispatch(Route $route): void
{
if ($this->issetRoute($route)) {
(new $this->routes[$route->getCommandName()])();
$call = new $this->routes[$route->getCommandName()];

Check failure on line 24 in code/src/Router/Router.php

View workflow job for this annotation

GitHub Actions / phpcs

Parentheses must be used when instantiating a new class
$call();
} else {
throw new Exception('Command not found');
}
Expand All @@ -40,4 +41,4 @@ private function issetRoute(Route $route): bool
{
return isset($this->routes[$route->getCommandName()]);
}
}
}

0 comments on commit 40a75b4

Please sign in to comment.