@@ -58,10 +58,10 @@ |
||
58 | 58 | */ |
59 | 59 | public function getChunkSize(): ?int |
60 | 60 | { |
61 | - if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) { |
|
61 | + if (\is_null($this->config['chunkSize']) || (int)$this->config['chunkSize'] < 0){ |
|
62 | 62 | return null; |
63 | 63 | } |
64 | 64 | |
65 | - return (int) $this->config['chunkSize']; |
|
65 | + return (int)$this->config['chunkSize']; |
|
66 | 66 | } |
67 | 67 | } |
@@ -58,7 +58,8 @@ |
||
58 | 58 | */ |
59 | 59 | public function getChunkSize(): ?int |
60 | 60 | { |
61 | - if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) { |
|
61 | + if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) |
|
62 | + { |
|
62 | 63 | return null; |
63 | 64 | } |
64 | 65 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function __construct( |
14 | 14 | private readonly ProcessRunner $processRunner |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | public function __construct( |
14 | 14 | private readonly TagParserInterface $parser, |
15 | 15 | private ?string $gitDirectory = null |
16 | - ) { |
|
17 | - if ($gitDirectory === null) { |
|
16 | + ){ |
|
17 | + if ($gitDirectory === null){ |
|
18 | 18 | $this->gitDirectory = \dirname(__DIR__); |
19 | 19 | } |
20 | 20 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | $mostRecentVersion = $this->findMostRecentVersion($version); |
33 | 33 | |
34 | 34 | // no tag yet |
35 | - if ($mostRecentVersion === null) { |
|
35 | + if ($mostRecentVersion === null){ |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | 39 | // validation |
40 | 40 | $mostRecentVersion = new Version(\strtolower($mostRecentVersion)); |
41 | - if ($version->isGreaterThan($mostRecentVersion)) { |
|
41 | + if ($version->isGreaterThan($mostRecentVersion)){ |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | private function findMostRecentVersion(Version $version): ?string |
53 | 53 | { |
54 | 54 | $tags = []; |
55 | - foreach ($this->parser->parse($this->gitDirectory) as $tag) { |
|
55 | + foreach ($this->parser->parse($this->gitDirectory) as $tag){ |
|
56 | 56 | $tag = new Version(\strtolower($tag)); |
57 | 57 | |
58 | 58 | // all previous major versions |
59 | - if ($version->getMajor()->getValue() > $tag->getMajor()->getValue()) { |
|
59 | + if ($version->getMajor()->getValue() > $tag->getMajor()->getValue()){ |
|
60 | 60 | $tags[] = $tag; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // all minor versions up to the requested in the requested major version |
64 | - if ($version->getMajor()->getValue() === $tag->getMajor()->getValue()) { |
|
65 | - if ($version->getMinor()->getValue() >= $tag->getMinor()->getValue()) { |
|
64 | + if ($version->getMajor()->getValue() === $tag->getMajor()->getValue()){ |
|
65 | + if ($version->getMinor()->getValue() >= $tag->getMinor()->getValue()){ |
|
66 | 66 | $tags[] = $tag; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - if ($tags === []) { |
|
71 | + if ($tags === []){ |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | private readonly TagParserInterface $parser, |
15 | 15 | private ?string $gitDirectory = null |
16 | 16 | ) { |
17 | - if ($gitDirectory === null) { |
|
17 | + if ($gitDirectory === null) |
|
18 | + { |
|
18 | 19 | $this->gitDirectory = \dirname(__DIR__); |
19 | 20 | } |
20 | 21 | } |
@@ -32,13 +33,15 @@ discard block |
||
32 | 33 | $mostRecentVersion = $this->findMostRecentVersion($version); |
33 | 34 | |
34 | 35 | // no tag yet |
35 | - if ($mostRecentVersion === null) { |
|
36 | + if ($mostRecentVersion === null) |
|
37 | + { |
|
36 | 38 | return; |
37 | 39 | } |
38 | 40 | |
39 | 41 | // validation |
40 | 42 | $mostRecentVersion = new Version(\strtolower($mostRecentVersion)); |
41 | - if ($version->isGreaterThan($mostRecentVersion)) { |
|
43 | + if ($version->isGreaterThan($mostRecentVersion)) |
|
44 | + { |
|
42 | 45 | return; |
43 | 46 | } |
44 | 47 | |
@@ -52,23 +55,28 @@ discard block |
||
52 | 55 | private function findMostRecentVersion(Version $version): ?string |
53 | 56 | { |
54 | 57 | $tags = []; |
55 | - foreach ($this->parser->parse($this->gitDirectory) as $tag) { |
|
58 | + foreach ($this->parser->parse($this->gitDirectory) as $tag) |
|
59 | + { |
|
56 | 60 | $tag = new Version(\strtolower($tag)); |
57 | 61 | |
58 | 62 | // all previous major versions |
59 | - if ($version->getMajor()->getValue() > $tag->getMajor()->getValue()) { |
|
63 | + if ($version->getMajor()->getValue() > $tag->getMajor()->getValue()) |
|
64 | + { |
|
60 | 65 | $tags[] = $tag; |
61 | 66 | } |
62 | 67 | |
63 | 68 | // all minor versions up to the requested in the requested major version |
64 | - if ($version->getMajor()->getValue() === $tag->getMajor()->getValue()) { |
|
65 | - if ($version->getMinor()->getValue() >= $tag->getMinor()->getValue()) { |
|
69 | + if ($version->getMajor()->getValue() === $tag->getMajor()->getValue()) |
|
70 | + { |
|
71 | + if ($version->getMinor()->getValue() >= $tag->getMinor()->getValue()) |
|
72 | + { |
|
66 | 73 | $tags[] = $tag; |
67 | 74 | } |
68 | 75 | } |
69 | 76 | } |
70 | 77 | |
71 | - if ($tags === []) { |
|
78 | + if ($tags === []) |
|
79 | + { |
|
72 | 80 | return null; |
73 | 81 | } |
74 | 82 |
@@ -43,15 +43,15 @@ |
||
43 | 43 | */ |
44 | 44 | public function getHandler(): ?Autowire |
45 | 45 | { |
46 | - if (empty($this->config['handler'])) { |
|
46 | + if (empty($this->config['handler'])){ |
|
47 | 47 | return null; |
48 | 48 | } |
49 | 49 | |
50 | - if ($this->config['handler'] instanceof Autowire) { |
|
50 | + if ($this->config['handler'] instanceof Autowire){ |
|
51 | 51 | return $this->config['handler']; |
52 | 52 | } |
53 | 53 | |
54 | - if (\class_exists($this->config['handler'])) { |
|
54 | + if (\class_exists($this->config['handler'])){ |
|
55 | 55 | return new Autowire($this->config['handler']); |
56 | 56 | } |
57 | 57 |
@@ -43,15 +43,18 @@ |
||
43 | 43 | */ |
44 | 44 | public function getHandler(): ?Autowire |
45 | 45 | { |
46 | - if (empty($this->config['handler'])) { |
|
46 | + if (empty($this->config['handler'])) |
|
47 | + { |
|
47 | 48 | return null; |
48 | 49 | } |
49 | 50 | |
50 | - if ($this->config['handler'] instanceof Autowire) { |
|
51 | + if ($this->config['handler'] instanceof Autowire) |
|
52 | + { |
|
51 | 53 | return $this->config['handler']; |
52 | 54 | } |
53 | 55 | |
54 | - if (\class_exists($this->config['handler'])) { |
|
56 | + if (\class_exists($this->config['handler'])) |
|
57 | + { |
|
55 | 58 | return new Autowire($this->config['handler']); |
56 | 59 | } |
57 | 60 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct( |
15 | 15 | private readonly SessionInterface $session, |
16 | 16 | private readonly string $name |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function get(string $name, mixed $default = null): mixed |
77 | 77 | { |
78 | - if (!$this->has($name)) { |
|
78 | + if (!$this->has($name)){ |
|
79 | 79 | return $default; |
80 | 80 | } |
81 | 81 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | $this->session->resume(); |
131 | 131 | |
132 | - if (!isset($_SESSION[$this->name])) { |
|
132 | + if (!isset($_SESSION[$this->name])){ |
|
133 | 133 | $_SESSION[$this->name] = []; |
134 | 134 | } |
135 | 135 | } |
@@ -75,7 +75,8 @@ discard block |
||
75 | 75 | |
76 | 76 | public function get(string $name, mixed $default = null): mixed |
77 | 77 | { |
78 | - if (!$this->has($name)) { |
|
78 | + if (!$this->has($name)) |
|
79 | + { |
|
79 | 80 | return $default; |
80 | 81 | } |
81 | 82 | |
@@ -129,7 +130,8 @@ discard block |
||
129 | 130 | { |
130 | 131 | $this->session->resume(); |
131 | 132 | |
132 | - if (!isset($_SESSION[$this->name])) { |
|
133 | + if (!isset($_SESSION[$this->name])) |
|
134 | + { |
|
133 | 135 | $_SESSION[$this->name] = []; |
134 | 136 | } |
135 | 137 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct( |
15 | 15 | private readonly FilesInterface $files, |
16 | 16 | private readonly string $directory |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function close(): bool |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function gc(int $maxlifetime): int |
37 | 37 | { |
38 | - foreach ($this->files->getFiles($this->directory) as $filename) { |
|
39 | - if ($this->files->time($filename) < \time() - $maxlifetime) { |
|
38 | + foreach ($this->files->getFiles($this->directory) as $filename){ |
|
39 | + if ($this->files->time($filename) < \time() - $maxlifetime){ |
|
40 | 40 | $this->files->delete($filename); |
41 | 41 | } |
42 | 42 | } |
@@ -35,8 +35,10 @@ |
||
35 | 35 | */ |
36 | 36 | public function gc(int $maxlifetime): int |
37 | 37 | { |
38 | - foreach ($this->files->getFiles($this->directory) as $filename) { |
|
39 | - if ($this->files->time($filename) < \time() - $maxlifetime) { |
|
38 | + foreach ($this->files->getFiles($this->directory) as $filename) |
|
39 | + { |
|
40 | + if ($this->files->time($filename) < \time() - $maxlifetime) |
|
41 | + { |
|
40 | 42 | $this->files->delete($filename); |
41 | 43 | } |
42 | 44 | } |
@@ -10,33 +10,33 @@ |
||
10 | 10 | |
11 | 11 | final class PhpSerializer implements SerializerInterface |
12 | 12 | { |
13 | - public function serialize(mixed $payload): string|\Stringable |
|
13 | + public function serialize(mixed $payload): string | \Stringable |
|
14 | 14 | { |
15 | 15 | return \serialize($payload); |
16 | 16 | } |
17 | 17 | |
18 | - public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
|
18 | + public function unserialize(\Stringable | string $payload, object | string | null $type = null): mixed |
|
19 | 19 | { |
20 | - if (\is_object($type)) { |
|
20 | + if (\is_object($type)){ |
|
21 | 21 | $type = $type::class; |
22 | 22 | } |
23 | 23 | |
24 | - if (\is_string($type) && !\class_exists($type) && !\interface_exists($type)) { |
|
24 | + if (\is_string($type) && !\class_exists($type) && !\interface_exists($type)){ |
|
25 | 25 | throw new InvalidArgumentException(\sprintf('Class or interface `%s` doesn\'t exist.', $type)); |
26 | 26 | } |
27 | 27 | |
28 | 28 | return $this->runUnserialize($payload, $type); |
29 | 29 | } |
30 | 30 | |
31 | - private function runUnserialize(\Stringable|string $payload, ?string $type = null): mixed |
|
31 | + private function runUnserialize(\Stringable | string $payload, ?string $type = null): mixed |
|
32 | 32 | { |
33 | - $result = \unserialize((string) $payload, $type ? [] : ['allowed_classes' => false]); |
|
33 | + $result = \unserialize((string)$payload, $type ? [] : ['allowed_classes' => false]); |
|
34 | 34 | |
35 | - if ($result === false) { |
|
35 | + if ($result === false){ |
|
36 | 36 | throw new UnserializeException('Failed to unserialize data.'); |
37 | 37 | } |
38 | 38 | |
39 | - if ($type !== null && !$result instanceof $type) { |
|
39 | + if ($type !== null && !$result instanceof $type){ |
|
40 | 40 | throw new InvalidArgumentException(\sprintf( |
41 | 41 | 'Data received after unserializing must be of type: `%s`, received `%s`', |
42 | 42 | $type, |
@@ -17,11 +17,13 @@ discard block |
||
17 | 17 | |
18 | 18 | public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
19 | 19 | { |
20 | - if (\is_object($type)) { |
|
20 | + if (\is_object($type)) |
|
21 | + { |
|
21 | 22 | $type = $type::class; |
22 | 23 | } |
23 | 24 | |
24 | - if (\is_string($type) && !\class_exists($type) && !\interface_exists($type)) { |
|
25 | + if (\is_string($type) && !\class_exists($type) && !\interface_exists($type)) |
|
26 | + { |
|
25 | 27 | throw new InvalidArgumentException(\sprintf('Class or interface `%s` doesn\'t exist.', $type)); |
26 | 28 | } |
27 | 29 | |
@@ -32,11 +34,13 @@ discard block |
||
32 | 34 | { |
33 | 35 | $result = \unserialize((string) $payload, $type ? [] : ['allowed_classes' => false]); |
34 | 36 | |
35 | - if ($result === false) { |
|
37 | + if ($result === false) |
|
38 | + { |
|
36 | 39 | throw new UnserializeException('Failed to unserialize data.'); |
37 | 40 | } |
38 | 41 | |
39 | - if ($type !== null && !$result instanceof $type) { |
|
42 | + if ($type !== null && !$result instanceof $type) |
|
43 | + { |
|
40 | 44 | throw new InvalidArgumentException(\sprintf( |
41 | 45 | 'Data received after unserializing must be of type: `%s`, received `%s`', |
42 | 46 | $type, |
@@ -25,7 +25,7 @@ |
||
25 | 25 | return ($this->serializeCallback)($payload); |
26 | 26 | } |
27 | 27 | |
28 | - public function unserialize(string|\Stringable $payload, string|object|null $type = null): mixed |
|
28 | + public function unserialize(string | \Stringable $payload, string | object | null $type = null): mixed |
|
29 | 29 | { |
30 | 30 | return ($this->unserializeCallback)($payload, $type); |
31 | 31 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @throws SerializeException |
16 | 16 | */ |
17 | - public function serialize(mixed $payload): string|\Stringable |
|
17 | + public function serialize(mixed $payload): string | \Stringable |
|
18 | 18 | { |
19 | - try { |
|
19 | + try{ |
|
20 | 20 | return \json_encode($payload, JSON_THROW_ON_ERROR); |
21 | - } catch (\JsonException $e) { |
|
21 | + }catch (\JsonException $e){ |
|
22 | 22 | throw new SerializeException($e->getMessage(), $e->getCode(), $e); |
23 | 23 | } |
24 | 24 | } |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @throws \JsonException |
28 | 28 | */ |
29 | - public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
|
29 | + public function unserialize(\Stringable | string $payload, object | string | null $type = null): mixed |
|
30 | 30 | { |
31 | - if ($type !== null) { |
|
31 | + if ($type !== null){ |
|
32 | 32 | throw new InvalidArgumentException( |
33 | 33 | \sprintf('Serializer `%s` does not support data hydration to an object.', self::class) |
34 | 34 | ); |
35 | 35 | } |
36 | 36 | |
37 | - try { |
|
38 | - return \json_decode((string) $payload, true, 512, JSON_THROW_ON_ERROR); |
|
39 | - } catch (\JsonException $e) { |
|
37 | + try{ |
|
38 | + return \json_decode((string)$payload, true, 512, JSON_THROW_ON_ERROR); |
|
39 | + }catch (\JsonException $e){ |
|
40 | 40 | throw new UnserializeException($e->getMessage(), $e->getCode(), $e); |
41 | 41 | } |
42 | 42 | } |
@@ -16,9 +16,12 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function serialize(mixed $payload): string|\Stringable |
18 | 18 | { |
19 | - try { |
|
19 | + try |
|
20 | + { |
|
20 | 21 | return \json_encode($payload, JSON_THROW_ON_ERROR); |
21 | - } catch (\JsonException $e) { |
|
22 | + } |
|
23 | + catch (\JsonException $e) |
|
24 | + { |
|
22 | 25 | throw new SerializeException($e->getMessage(), $e->getCode(), $e); |
23 | 26 | } |
24 | 27 | } |
@@ -28,15 +31,19 @@ discard block |
||
28 | 31 | */ |
29 | 32 | public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
30 | 33 | { |
31 | - if ($type !== null) { |
|
34 | + if ($type !== null) |
|
35 | + { |
|
32 | 36 | throw new InvalidArgumentException( |
33 | 37 | \sprintf('Serializer `%s` does not support data hydration to an object.', self::class) |
34 | 38 | ); |
35 | 39 | } |
36 | 40 | |
37 | - try { |
|
41 | + try |
|
42 | + { |
|
38 | 43 | return \json_decode((string) $payload, true, 512, JSON_THROW_ON_ERROR); |
39 | - } catch (\JsonException $e) { |
|
44 | + } |
|
45 | + catch (\JsonException $e) |
|
46 | + { |
|
40 | 47 | throw new UnserializeException($e->getMessage(), $e->getCode(), $e); |
41 | 48 | } |
42 | 49 | } |