Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 65e4621

Browse files
authored
fixes #75 (#289)
* fixes #75 * remove loop | refactor writer * cs fixes * small refactor on dispatcher | added log for writer * remove xmlable | added some functions * add if check * Scrutinizer Auto-Fixes (#290) This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com * added a new class for handler * fixed tests * phpdoc fixes * Added more tests * remove on in writer * Scrutinizer Auto-Fixes (#291) This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com * added more tests * added more tests * phpdoc fix * Scrutinizer Auto-Fixes (#292) This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
1 parent a1de5f7 commit 65e4621

30 files changed

+1053
-737
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,10 @@
7070
<testsuite name="Narrowspark Http Component Test Suite">
7171
<directory>./src/Viserio/Http/Tests</directory>
7272
</testsuite>
73-
<!-- <testsuite name="Narrowspark Log Component Test Suite">
73+
<testsuite name="Narrowspark Log Component Test Suite">
7474
<directory>./src/Viserio/Log/Tests</directory>
7575
</testsuite>
76-
<testsuite name="Narrowspark Loop Component Test Suite">
77-
<directory>./src/Viserio/Loop/Tests</directory>
78-
</testsuite>
79-
<testsuite name="Narrowspark Mail Component Test Suite">
76+
<!-- <testsuite name="Narrowspark Mail Component Test Suite">
8077
<directory>./src/Viserio/Mail/Tests</directory>
8178
</testsuite> -->
8279
<testsuite name="Narrowspark Middleware Component Test Suite">

src/Viserio/Contracts/Log/Log.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
namespace Viserio\Contracts\Log;
3+
4+
use Psr\Log\LoggerInterface as PsrLoggerInterface;
5+
6+
interface Log extends PsrLoggerInterface
7+
{
8+
/**
9+
* Register a file log handler.
10+
*
11+
* @param string $path
12+
* @param string $level
13+
* @param object|null $processor
14+
* @param object|null $formatter
15+
*
16+
* @return void
17+
*/
18+
public function useFiles(
19+
string $path,
20+
string $level = 'debug',
21+
$processor = null,
22+
$formatter = null
23+
);
24+
25+
/**
26+
* Register a daily file log handler.
27+
*
28+
* @param string $path
29+
* @param int $days
30+
* @param string $level
31+
* @param object|null $processor
32+
* @param object|null $formatter
33+
*
34+
* @return void
35+
*/
36+
public function useDailyFiles(
37+
string $path,
38+
int $days = 0,
39+
string $level = 'debug',
40+
$processor = null,
41+
$formatter = null
42+
);
43+
}

src/Viserio/Contracts/Logging/Log.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Viserio/Contracts/Loop/Loop.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/Viserio/Contracts/Loop/LoopInitializedException.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Viserio/Contracts/Loop/ResourceBusyException.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Viserio/Contracts/Loop/RunningException.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Viserio/Contracts/Loop/Timer.php

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/Viserio/Contracts/Loop/UnsupportedException.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Viserio/Contracts/Support/Xmlable.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Viserio/Events/Dispatcher.php

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,7 @@ public function emit(string $eventName, array $arguments = [], $continue = null)
9999
$listeners = $this->getListeners($eventName);
100100

101101
if ($continue === null) {
102-
foreach ($listeners as $listener) {
103-
$result = false;
104-
105-
if ($listener !== null) {
106-
$result = $this->invoker->call($listener, $arguments);
107-
}
108-
109-
if ($result === false) {
110-
return false;
111-
}
112-
}
113-
114-
return true;
102+
return $this->continueEmit($listeners, $arguments);
115103
}
116104

117105
$counter = count($listeners);
@@ -308,4 +296,30 @@ protected function removeListenerPattern(string $eventPattern, $listener)
308296
}
309297
}
310298
}
299+
300+
/**
301+
* If the continue is specified, this callback will be called every
302+
* time before the next event handler is called.
303+
*
304+
* @param array $listeners
305+
* @param array $arguments
306+
*
307+
* @return bool
308+
*/
309+
protected function continueEmit(array $listeners, array $arguments): bool
310+
{
311+
foreach ($listeners as $listener) {
312+
$result = false;
313+
314+
if ($listener !== null) {
315+
$result = $this->invoker->call($listener, $arguments);
316+
}
317+
318+
if ($result === false) {
319+
return false;
320+
}
321+
}
322+
323+
return true;
324+
}
311325
}

src/Viserio/Http/RequestFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ final class RequestFactory implements RequestFactoryContract
88
{
99
/**
1010
* {@inheritdoc}
11+
*
12+
* @codeCoverageIgnore
1113
*/
1214
public function createRequest(
1315
string $method = 'GET',

src/Viserio/Http/ResponseFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ final class ResponseFactory implements ResponseFactoryContract
88
{
99
/**
1010
* {@inheritdoc}
11+
*
12+
* @codeCoverageIgnore
1113
*/
1214
public function createResponse(
1315
int $code = 200

src/Viserio/Http/ServerRequestFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public function createServerRequestFromGlobals(): ServerRequestInterface
3333

3434
/**
3535
* {@inheritdoc}
36+
*
37+
* @codeCoverageIgnore
3638
*/
3739
public function createServerRequest(string $method, $uri): ServerRequestInterface
3840
{

src/Viserio/Http/StreamFactory.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ final class StreamFactory implements StreamFactoryContract
88
{
99
/**
1010
* {@inheritdoc}
11+
*
12+
* @codeCoverageIgnore
1113
*/
1214
public function createStream(): StreamInterface
1315
{
@@ -16,6 +18,8 @@ public function createStream(): StreamInterface
1618

1719
/**
1820
* {@inheritdoc}
21+
*
22+
* @codeCoverageIgnore
1923
*/
2024
public function createStreamFromCallback(callable $callback): StreamInterface
2125
{
@@ -24,6 +28,8 @@ public function createStreamFromCallback(callable $callback): StreamInterface
2428

2529
/**
2630
* {@inheritdoc}
31+
*
32+
* @codeCoverageIgnore
2733
*/
2834
public function createStreamFromResource($body): StreamInterface
2935
{
@@ -32,6 +38,8 @@ public function createStreamFromResource($body): StreamInterface
3238

3339
/**
3440
* {@inheritdoc}
41+
*
42+
* @codeCoverageIgnore
3543
*/
3644
public function createStreamFromString(string $body): StreamInterface
3745
{

src/Viserio/Http/UploadedFileFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ final class UploadedFileFactory implements UploadedFileFactoryContract
88
{
99
/**
1010
* {@inheritdoc}
11+
*
12+
* @codeCoverageIgnore
1113
*/
1214
public function createUploadedFile(
1315
$file,

0 commit comments

Comments
 (0)