@@ -51,15 +51,15 @@ discard block |
||
| 51 | 51 | public function withValue($value): ?SpecificationInterface |
| 52 | 52 | { |
| 53 | 53 | $paginator = clone $this; |
| 54 | - if (!is_array($value)) { |
|
| 54 | + if (!is_array($value)){ |
|
| 55 | 55 | return $paginator; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if (isset($value['limit']) && $paginator->limitValue->accepts($value['limit'])) { |
|
| 58 | + if (isset($value['limit']) && $paginator->limitValue->accepts($value['limit'])){ |
|
| 59 | 59 | $paginator->limit = $paginator->limitValue->convert($value['limit']); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if (isset($value['page']) && is_numeric($value['page'])) { |
|
| 62 | + if (isset($value['page']) && is_numeric($value['page'])){ |
|
| 63 | 63 | $paginator->page = max((int)$value['page'], 1); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | public function getSpecifications(): array |
| 73 | 73 | { |
| 74 | 74 | $specifications = [new Limit($this->limit)]; |
| 75 | - if ($this->page > 1) { |
|
| 75 | + if ($this->page > 1){ |
|
| 76 | 76 | $specifications[] = new Offset($this->limit * ($this->page - 1)); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -51,15 +51,18 @@ discard block |
||
| 51 | 51 | public function withValue($value): ?SpecificationInterface |
| 52 | 52 | { |
| 53 | 53 | $paginator = clone $this; |
| 54 | - if (!is_array($value)) { |
|
| 54 | + if (!is_array($value)) |
|
| 55 | + { |
|
| 55 | 56 | return $paginator; |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | - if (isset($value['limit']) && $paginator->limitValue->accepts($value['limit'])) { |
|
| 59 | + if (isset($value['limit']) && $paginator->limitValue->accepts($value['limit'])) |
|
| 60 | + { |
|
| 59 | 61 | $paginator->limit = $paginator->limitValue->convert($value['limit']); |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | - if (isset($value['page']) && is_numeric($value['page'])) { |
|
| 64 | + if (isset($value['page']) && is_numeric($value['page'])) |
|
| 65 | + { |
|
| 63 | 66 | $paginator->page = max((int)$value['page'], 1); |
| 64 | 67 | } |
| 65 | 68 | |
@@ -72,7 +75,8 @@ discard block |
||
| 72 | 75 | public function getSpecifications(): array |
| 73 | 76 | { |
| 74 | 77 | $specifications = [new Limit($this->limit)]; |
| 75 | - if ($this->page > 1) { |
|
| 78 | + if ($this->page > 1) |
|
| 79 | + { |
|
| 76 | 80 | $specifications[] = new Offset($this->limit * ($this->page - 1)); |
| 77 | 81 | } |
| 78 | 82 | |
@@ -41,25 +41,25 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function compile($source, SpecificationInterface ...$specifications) |
| 43 | 43 | { |
| 44 | - if ($source === null) { |
|
| 44 | + if ($source === null){ |
|
| 45 | 45 | return null; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - foreach ($specifications as $specification) { |
|
| 49 | - if ($specification instanceof SequenceInterface) { |
|
| 48 | + foreach ($specifications as $specification){ |
|
| 49 | + if ($specification instanceof SequenceInterface){ |
|
| 50 | 50 | return $this->compile($source, ...$specification->getSpecifications()); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $isWritten = false; |
| 54 | - foreach ($this->writers as $writer) { |
|
| 54 | + foreach ($this->writers as $writer){ |
|
| 55 | 55 | $result = $writer->write($source, $specification, $this); |
| 56 | - if ($result !== null) { |
|
| 56 | + if ($result !== null){ |
|
| 57 | 57 | $source = $result; |
| 58 | 58 | $isWritten = true; |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ($isWritten) { |
|
| 62 | + if ($isWritten){ |
|
| 63 | 63 | continue; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -41,25 +41,31 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function compile($source, SpecificationInterface ...$specifications) |
| 43 | 43 | { |
| 44 | - if ($source === null) { |
|
| 44 | + if ($source === null) |
|
| 45 | + { |
|
| 45 | 46 | return null; |
| 46 | 47 | } |
| 47 | 48 | |
| 48 | - foreach ($specifications as $specification) { |
|
| 49 | - if ($specification instanceof SequenceInterface) { |
|
| 49 | + foreach ($specifications as $specification) |
|
| 50 | + { |
|
| 51 | + if ($specification instanceof SequenceInterface) |
|
| 52 | + { |
|
| 50 | 53 | return $this->compile($source, ...$specification->getSpecifications()); |
| 51 | 54 | } |
| 52 | 55 | |
| 53 | 56 | $isWritten = false; |
| 54 | - foreach ($this->writers as $writer) { |
|
| 57 | + foreach ($this->writers as $writer) |
|
| 58 | + { |
|
| 55 | 59 | $result = $writer->write($source, $specification, $this); |
| 56 | - if ($result !== null) { |
|
| 60 | + if ($result !== null) |
|
| 61 | + { |
|
| 57 | 62 | $source = $result; |
| 58 | 63 | $isWritten = true; |
| 59 | 64 | } |
| 60 | 65 | } |
| 61 | 66 | |
| 62 | - if ($isWritten) { |
|
| 67 | + if ($isWritten) |
|
| 68 | + { |
|
| 63 | 69 | continue; |
| 64 | 70 | } |
| 65 | 71 | |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | $paginator = $paginator->withValue($value); |
| 56 | 56 | |
| 57 | 57 | $specifications = []; |
| 58 | - foreach ($paginator->getSpecifications() as $specification) { |
|
| 58 | + foreach ($paginator->getSpecifications() as $specification){ |
|
| 59 | 59 | $specifications[] = get_class($specification); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -55,7 +55,8 @@ |
||
| 55 | 55 | $paginator = $paginator->withValue($value); |
| 56 | 56 | |
| 57 | 57 | $specifications = []; |
| 58 | - foreach ($paginator->getSpecifications() as $specification) { |
|
| 58 | + foreach ($paginator->getSpecifications() as $specification) |
|
| 59 | + { |
|
| 59 | 60 | $specifications[] = get_class($specification); |
| 60 | 61 | } |
| 61 | 62 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public function testInitValue($value, ?string $exception): void |
| 29 | 29 | { |
| 30 | 30 | $this->assertTrue(true); |
| 31 | - if ($exception !== null) { |
|
| 31 | + if ($exception !== null){ |
|
| 32 | 32 | $this->expectException($exception); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | new stdClass() |
| 82 | 82 | ]; |
| 83 | 83 | |
| 84 | - foreach ($incorrectValues as $incorrectValue) { |
|
| 84 | + foreach ($incorrectValues as $incorrectValue){ |
|
| 85 | 85 | yield[[1, 2], $incorrectValue, true]; |
| 86 | 86 | yield[new IntValue(), $incorrectValue, false]; |
| 87 | 87 | } |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | ): void { |
| 164 | 164 | $filters = $between->getFilters(true); |
| 165 | 165 | |
| 166 | - if ($isOriginal) { |
|
| 166 | + if ($isOriginal){ |
|
| 167 | 167 | $this->assertCount(1, $filters); |
| 168 | 168 | $this->assertInstanceOf(Filter\Between::class, $filters[0]); |
| 169 | - } else { |
|
| 169 | + }else{ |
|
| 170 | 170 | $this->assertCount(2, $filters); |
| 171 | 171 | $this->assertInstanceOf($from, $filters[0]); |
| 172 | 172 | $this->assertInstanceOf($to, $filters[1]); |
@@ -28,7 +28,8 @@ discard block |
||
| 28 | 28 | public function testInitValue($value, ?string $exception): void |
| 29 | 29 | { |
| 30 | 30 | $this->assertTrue(true); |
| 31 | - if ($exception !== null) { |
|
| 31 | + if ($exception !== null) |
|
| 32 | + { |
|
| 32 | 33 | $this->expectException($exception); |
| 33 | 34 | } |
| 34 | 35 | |
@@ -81,7 +82,8 @@ discard block |
||
| 81 | 82 | new stdClass() |
| 82 | 83 | ]; |
| 83 | 84 | |
| 84 | - foreach ($incorrectValues as $incorrectValue) { |
|
| 85 | + foreach ($incorrectValues as $incorrectValue) |
|
| 86 | + { |
|
| 85 | 87 | yield[[1, 2], $incorrectValue, true]; |
| 86 | 88 | yield[new IntValue(), $incorrectValue, false]; |
| 87 | 89 | } |
@@ -163,10 +165,13 @@ discard block |
||
| 163 | 165 | ): void { |
| 164 | 166 | $filters = $between->getFilters(true); |
| 165 | 167 | |
| 166 | - if ($isOriginal) { |
|
| 168 | + if ($isOriginal) |
|
| 169 | + { |
|
| 167 | 170 | $this->assertCount(1, $filters); |
| 168 | 171 | $this->assertInstanceOf(Filter\Between::class, $filters[0]); |
| 169 | - } else { |
|
| 172 | + } |
|
| 173 | + else |
|
| 174 | + { |
|
| 170 | 175 | $this->assertCount(2, $filters); |
| 171 | 176 | $this->assertInstanceOf($from, $filters[0]); |
| 172 | 177 | $this->assertInstanceOf($to, $filters[1]); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function testInitValue($expression, array $value, ?string $exception): void |
| 30 | 30 | { |
| 31 | 31 | $this->assertTrue(true); |
| 32 | - if ($exception !== null) { |
|
| 32 | + if ($exception !== null){ |
|
| 33 | 33 | $this->expectException($exception); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | new stdClass() |
| 89 | 89 | ]; |
| 90 | 90 | |
| 91 | - foreach ($incorrectValues as $incorrectValue) { |
|
| 91 | + foreach ($incorrectValues as $incorrectValue){ |
|
| 92 | 92 | yield[1, $incorrectValue, true]; |
| 93 | 93 | yield[new IntValue(), $incorrectValue, false]; |
| 94 | 94 | } |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | ): void { |
| 147 | 147 | $filters = $between->getFilters(true); |
| 148 | 148 | |
| 149 | - if ($isOriginal) { |
|
| 149 | + if ($isOriginal){ |
|
| 150 | 150 | $this->assertCount(1, $filters); |
| 151 | 151 | $this->assertInstanceOf(Filter\ValueBetween::class, $filters[0]); |
| 152 | - } else { |
|
| 152 | + }else{ |
|
| 153 | 153 | $this->assertCount(2, $filters); |
| 154 | 154 | $this->assertInstanceOf($from, $filters[0]); |
| 155 | 155 | $this->assertInstanceOf($to, $filters[1]); |
@@ -29,7 +29,8 @@ discard block |
||
| 29 | 29 | public function testInitValue($expression, array $value, ?string $exception): void |
| 30 | 30 | { |
| 31 | 31 | $this->assertTrue(true); |
| 32 | - if ($exception !== null) { |
|
| 32 | + if ($exception !== null) |
|
| 33 | + { |
|
| 33 | 34 | $this->expectException($exception); |
| 34 | 35 | } |
| 35 | 36 | |
@@ -88,7 +89,8 @@ discard block |
||
| 88 | 89 | new stdClass() |
| 89 | 90 | ]; |
| 90 | 91 | |
| 91 | - foreach ($incorrectValues as $incorrectValue) { |
|
| 92 | + foreach ($incorrectValues as $incorrectValue) |
|
| 93 | + { |
|
| 92 | 94 | yield[1, $incorrectValue, true]; |
| 93 | 95 | yield[new IntValue(), $incorrectValue, false]; |
| 94 | 96 | } |
@@ -146,10 +148,13 @@ discard block |
||
| 146 | 148 | ): void { |
| 147 | 149 | $filters = $between->getFilters(true); |
| 148 | 150 | |
| 149 | - if ($isOriginal) { |
|
| 151 | + if ($isOriginal) |
|
| 152 | + { |
|
| 150 | 153 | $this->assertCount(1, $filters); |
| 151 | 154 | $this->assertInstanceOf(Filter\ValueBetween::class, $filters[0]); |
| 152 | - } else { |
|
| 155 | + } |
|
| 156 | + else |
|
| 157 | + { |
|
| 153 | 158 | $this->assertCount(2, $filters); |
| 154 | 159 | $this->assertInstanceOf($from, $filters[0]); |
| 155 | 160 | $this->assertInstanceOf($to, $filters[1]); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function testMask(?string $mask, ?string $expectedException): void |
| 27 | 27 | { |
| 28 | - if ($expectedException !== null) { |
|
| 28 | + if ($expectedException !== null){ |
|
| 29 | 29 | $this->expectException($expectedException); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $masks = ['valid', 'nil', 'v1', 'v2', 'v3', 'v4', 'v5']; |
| 76 | 76 | $random = bin2hex(random_bytes(10)); |
| 77 | - foreach ($masks as $mask) { |
|
| 77 | + foreach ($masks as $mask){ |
|
| 78 | 78 | yield from [ |
| 79 | 79 | [$mask, $random, false], |
| 80 | 80 | [null, $random, false], |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $uuid5 = Uuid::uuid5($ns, 'name')->toString(); |
| 90 | 90 | $uuids = [$nil, $uuid1, $uuid3, $uuid4, $uuid5]; |
| 91 | 91 | |
| 92 | - foreach ($uuids as $uuid) { |
|
| 92 | + foreach ($uuids as $uuid){ |
|
| 93 | 93 | yield from[ |
| 94 | 94 | ['valid', $uuid, true], |
| 95 | 95 | [null, $uuid, true], |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function testMask(?string $mask, ?string $expectedException): void |
| 27 | 27 | { |
| 28 | - if ($expectedException !== null) { |
|
| 28 | + if ($expectedException !== null) |
|
| 29 | + { |
|
| 29 | 30 | $this->expectException($expectedException); |
| 30 | 31 | } |
| 31 | 32 | |
@@ -74,7 +75,8 @@ discard block |
||
| 74 | 75 | { |
| 75 | 76 | $masks = ['valid', 'nil', 'v1', 'v2', 'v3', 'v4', 'v5']; |
| 76 | 77 | $random = bin2hex(random_bytes(10)); |
| 77 | - foreach ($masks as $mask) { |
|
| 78 | + foreach ($masks as $mask) |
|
| 79 | + { |
|
| 78 | 80 | yield from [ |
| 79 | 81 | [$mask, $random, false], |
| 80 | 82 | [null, $random, false], |
@@ -89,7 +91,8 @@ discard block |
||
| 89 | 91 | $uuid5 = Uuid::uuid5($ns, 'name')->toString(); |
| 90 | 92 | $uuids = [$nil, $uuid1, $uuid3, $uuid4, $uuid5]; |
| 91 | 93 | |
| 92 | - foreach ($uuids as $uuid) { |
|
| 94 | + foreach ($uuids as $uuid) |
|
| 95 | + { |
|
| 93 | 96 | yield from[ |
| 94 | 97 | ['valid', $uuid, true], |
| 95 | 98 | [null, $uuid, true], |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function testIncorrectEnum(ValueInterface $type, ?string $expectedException, ...$values): void |
| 27 | 27 | { |
| 28 | - if ($expectedException !== null) { |
|
| 28 | + if ($expectedException !== null){ |
|
| 29 | 29 | $this->expectException($expectedException); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | Value\StringValue::class, |
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | - foreach ($types as $type) { |
|
| 54 | + foreach ($types as $type){ |
|
| 55 | 55 | yield [new $type(), ValueException::class]; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function testIncorrectEnum(ValueInterface $type, ?string $expectedException, ...$values): void |
| 27 | 27 | { |
| 28 | - if ($expectedException !== null) { |
|
| 28 | + if ($expectedException !== null) |
|
| 29 | + { |
|
| 29 | 30 | $this->expectException($expectedException); |
| 30 | 31 | } |
| 31 | 32 | |
@@ -51,7 +52,8 @@ discard block |
||
| 51 | 52 | Value\StringValue::class, |
| 52 | 53 | ]; |
| 53 | 54 | |
| 54 | - foreach ($types as $type) { |
|
| 55 | + foreach ($types as $type) |
|
| 56 | + { |
|
| 55 | 57 | yield [new $type(), ValueException::class]; |
| 56 | 58 | } |
| 57 | 59 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | ?string $expectedException, |
| 29 | 29 | ?Value\RangeValue\Boundary ...$boundaries |
| 30 | 30 | ): void { |
| 31 | - if ($expectedException !== null) { |
|
| 31 | + if ($expectedException !== null){ |
|
| 32 | 32 | $this->expectException($expectedException); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | Value\StringValue::class, |
| 55 | 55 | ]; |
| 56 | 56 | |
| 57 | - foreach ($types as $type) { |
|
| 57 | + foreach ($types as $type){ |
|
| 58 | 58 | //both empty boundaries are forbidden |
| 59 | 59 | yield [new $type(), ValueException::class]; |
| 60 | 60 | } |
@@ -28,7 +28,8 @@ discard block |
||
| 28 | 28 | ?string $expectedException, |
| 29 | 29 | ?Value\RangeValue\Boundary ...$boundaries |
| 30 | 30 | ): void { |
| 31 | - if ($expectedException !== null) { |
|
| 31 | + if ($expectedException !== null) |
|
| 32 | + { |
|
| 32 | 33 | $this->expectException($expectedException); |
| 33 | 34 | } |
| 34 | 35 | |
@@ -54,7 +55,8 @@ discard block |
||
| 54 | 55 | Value\StringValue::class, |
| 55 | 56 | ]; |
| 56 | 57 | |
| 57 | - foreach ($types as $type) { |
|
| 58 | + foreach ($types as $type) |
|
| 59 | + { |
|
| 58 | 60 | //both empty boundaries are forbidden |
| 59 | 61 | yield [new $type(), ValueException::class]; |
| 60 | 62 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
| 23 | 23 | { |
| 24 | - if (!is_iterable($source)) { |
|
| 24 | + if (!is_iterable($source)){ |
|
| 25 | 25 | return [$source]; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -21,7 +21,8 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
| 23 | 23 | { |
| 24 | - if (!is_iterable($source)) { |
|
| 24 | + if (!is_iterable($source)) |
|
| 25 | + { |
|
| 25 | 26 | return [$source]; |
| 26 | 27 | } |
| 27 | 28 | |