Conditions | 7 |
Paths | 1 |
Total Lines | 69 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
44 | public function execute(): void |
||
45 | { |
||
46 | $this->worker->onWorkerStart = function () { |
||
47 | |||
48 | $connection = new AsyncTcpConnection($this->hostStream.'/'.self::CHANNEL_ACCESS.'/'.$this->streamType); |
||
49 | $connection->transport = 'ssl'; |
||
50 | |||
51 | $heartbeatTimerId = Timer::add(20, function() use ($connection) { |
||
52 | $connection->send(json_encode(["op" => "ping"])); |
||
53 | }); |
||
54 | |||
55 | /** |
||
56 | * Обработка соединения |
||
57 | * |
||
58 | * @param $connection |
||
59 | * @return void |
||
60 | */ |
||
61 | $connection->onConnect = function ($connection) use (&$heartbeatTimerId) { |
||
62 | $connection->send(json_encode(["op" => $this->operation, "args" => $this->topic])); |
||
63 | }; |
||
64 | |||
65 | $callback = $this->callback; |
||
66 | |||
67 | /** |
||
68 | * Обработка сообщений |
||
69 | * |
||
70 | * @param $connection |
||
71 | * @param $message |
||
72 | * @return void |
||
73 | * @throws \Exception |
||
74 | */ |
||
75 | $connection->onMessage = function ($connection, $message) use ($callback) { |
||
76 | $message = json_decode($message, true); |
||
77 | $responseDto = $this->getResponseClassname($this->streamType); |
||
78 | |||
79 | if (isset($message['success']) && !$message['success']) { |
||
80 | $responseDto = ExceptionResponse::class; |
||
81 | } else if (isset($message['success']) && $message['success']) { |
||
82 | $responseDto = WebSocketConnectionResponse::class; |
||
83 | } |
||
84 | |||
85 | $dtoMessage = ResponseDtoBuilder::make($responseDto, $message); |
||
86 | |||
87 | switch ($responseDto) { |
||
88 | case WebSocketConnectionResponse::class: |
||
89 | $callback->connectionHandle($dtoMessage, $connection); |
||
90 | break; |
||
91 | case ExceptionResponse::class: |
||
92 | $callback->apiExceptionHandler($dtoMessage, $connection); |
||
93 | break; |
||
94 | default: |
||
95 | $callback->handle($dtoMessage, $connection); |
||
96 | } |
||
97 | }; |
||
98 | |||
99 | /** |
||
100 | * При закрытии соединения удаляем таймер |
||
101 | * |
||
102 | * @param $connection |
||
103 | * @return void |
||
104 | */ |
||
105 | $this->worker->onClose = function ($connection) use (&$heartbeatTimerId) { |
||
106 | Timer::del($heartbeatTimerId); |
||
107 | }; |
||
108 | |||
109 | $connection->connect(); |
||
110 | }; |
||
111 | |||
112 | Worker::runAll(); |
||
113 | } |
||
115 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths