Skip to content

Commit

Permalink
fix: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Seriyyy95 committed Apr 25, 2024
1 parent c77bf8c commit 9c20a93
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ composer.lock
phpstan.neon
phpunit.xml
vendor
.idea

2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
},
"preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"bamarni-bin": {
"bin-links": true,
Expand Down
6 changes: 6 additions & 0 deletions src/Communication/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
namespace HeadlessChromium\Communication;

use Evenement\EventEmitter;
use HeadlessChromium\Communication\Socket\WaitForDataInterface;
use HeadlessChromium\Communication\Socket\SocketInterface;
use HeadlessChromium\Communication\Socket\Wrench;
use HeadlessChromium\Exception\CommunicationException;
use HeadlessChromium\Exception\CommunicationException\CantSyncEventsException;
use HeadlessChromium\Exception\CommunicationException\CannotReadResponse;
use HeadlessChromium\Exception\CommunicationException\InvalidResponse;
use HeadlessChromium\Exception\OperationTimedOut;
Expand Down Expand Up @@ -348,6 +350,10 @@ public function readLine()

public function processAllEvents(): void
{
if($this->wsClient instanceof WaitForDataInterface === false){
throw new CantSyncEventsException();
}

$hasData = $this->wsClient->waitForData(0);

if ($hasData) {
Expand Down
7 changes: 0 additions & 7 deletions src/Communication/Socket/MockSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,4 @@ public function disconnect($reason = 1000)

return true;
}

public function waitForData(float $maxSeconds): bool
{
// TODO: Implement wait if needed.

return !empty($this->receivedData);
}
}
2 changes: 0 additions & 2 deletions src/Communication/Socket/SocketInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ public function isConnected();
* @return bool
*/
public function disconnect($reason = 1000);

public function waitForData(float $maxSeconds): bool;
}
8 changes: 8 additions & 0 deletions src/Communication/Socket/WaitForDataInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace HeadlessChromium\Communication\Socket;

interface WaitForDataInterface
{
public function waitForData(float $maxSeconds): bool;
}
2 changes: 1 addition & 1 deletion src/Communication/Socket/Wrench.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Wrench\Client as WrenchClient;
use Wrench\Payload\Payload;

class Wrench implements SocketInterface, LoggerAwareInterface
class Wrench implements SocketInterface, LoggerAwareInterface, WaitForDataInterface
{
use LoggerAwareTrait;

Expand Down
10 changes: 10 additions & 0 deletions src/Exception/CommunicationException/CantSyncEventsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace HeadlessChromium\Exception\CommunicationException;

use HeadlessChromium\Exception\CommunicationException;

class CantSyncEventsException extends CommunicationException
{

}

0 comments on commit 9c20a93

Please sign in to comment.