@@ -25,9 +25,13 @@ |
||
25 | 25 | public function testFactoryAvailability(string $rule, bool $gotResult) |
26 | 26 | { |
27 | 27 | $factory = new Rules\Factory(); |
28 | - if (!$gotResult) $this->expectException(RuleException::class); |
|
28 | + if (!$gotResult) { |
|
29 | + $this->expectException(RuleException::class); |
|
30 | + } |
|
29 | 31 | $data = $factory->getRule($rule); |
30 | - if ($data) $this->assertInstanceOf('\kalanis\kw_rules\Rules\ARule', $data); |
|
32 | + if ($data) { |
|
33 | + $this->assertInstanceOf('\kalanis\kw_rules\Rules\ARule', $data); |
|
34 | + } |
|
31 | 35 | } |
32 | 36 | |
33 | 37 | public function inputsProvider() |
@@ -136,12 +136,12 @@ |
||
136 | 136 | public function sizeMatchProvider() |
137 | 137 | { |
138 | 138 | return [ |
139 | - ['6', '5', true, true, true ], |
|
139 | + ['6', '5', true, true, true], |
|
140 | 140 | ['5', '6', false, false, false], |
141 | - ['5', '5', false, true, false], |
|
142 | - ['6', '6', false, false, true ], |
|
143 | - ['4', '0', false, true, false], |
|
144 | - ['0', '7', false, false, true ], |
|
141 | + ['5', '5', false, true, false], |
|
142 | + ['6', '6', false, false, true], |
|
143 | + ['4', '0', false, true, false], |
|
144 | + ['0', '7', false, false, true], |
|
145 | 145 | ]; |
146 | 146 | } |
147 | 147 | } |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | $data = new File\ImageSizeEquals(); |
39 | 39 | $this->assertInstanceOf('\kalanis\kw_rules\Rules\File\AFileRule', $data); |
40 | 40 | $data->setAgainstValue([$maxSizeX, $maxSizeY]); |
41 | - if (!$matchEquals) $this->expectException(RuleException::class); |
|
41 | + if (!$matchEquals) { |
|
42 | + $this->expectException(RuleException::class); |
|
43 | + } |
|
42 | 44 | $data->validate($this->getMockImage()); |
43 | 45 | } |
44 | 46 | |
@@ -63,7 +65,9 @@ discard block |
||
63 | 65 | $data = new File\ImageSizeList(); |
64 | 66 | $this->assertInstanceOf('\kalanis\kw_rules\Rules\File\AFileRule', $data); |
65 | 67 | $data->setAgainstValue([[$maxSizeX, $maxSizeY]]); |
66 | - if (!$matchEquals) $this->expectException(RuleException::class); |
|
68 | + if (!$matchEquals) { |
|
69 | + $this->expectException(RuleException::class); |
|
70 | + } |
|
67 | 71 | $data->validate($this->getMockImage()); |
68 | 72 | } |
69 | 73 | |
@@ -95,7 +99,9 @@ discard block |
||
95 | 99 | $data = new File\ImageSizeMin(); |
96 | 100 | $this->assertInstanceOf('\kalanis\kw_rules\Rules\File\AFileRule', $data); |
97 | 101 | $data->setAgainstValue([$maxSizeX, $maxSizeY]); |
98 | - if (!$matchMin) $this->expectException(RuleException::class); |
|
102 | + if (!$matchMin) { |
|
103 | + $this->expectException(RuleException::class); |
|
104 | + } |
|
99 | 105 | $data->validate($this->getMockImage()); |
100 | 106 | } |
101 | 107 | |
@@ -121,7 +127,9 @@ discard block |
||
121 | 127 | $data = new File\ImageSizeMax(); |
122 | 128 | $this->assertInstanceOf('\kalanis\kw_rules\Rules\File\AFileRule', $data); |
123 | 129 | $data->setAgainstValue([$maxSizeX, $maxSizeY]); |
124 | - if (!$matchMax) $this->expectException(RuleException::class); |
|
130 | + if (!$matchMax) { |
|
131 | + $this->expectException(RuleException::class); |
|
132 | + } |
|
125 | 133 | $data->validate($this->getMockImage()); |
126 | 134 | } |
127 | 135 |
@@ -20,20 +20,20 @@ |
||
20 | 20 | { |
21 | 21 | return MockFile::init('foo', 'test1.gif', 'text/plain', |
22 | 22 | realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, 'data', 'tester.gif'])), |
23 | - 55, UPLOAD_ERR_OK ); |
|
23 | + 55, UPLOAD_ERR_OK); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | protected function getMockFile() |
27 | 27 | { |
28 | 28 | return MockFile::init('foo', 'text1.txt', 'text/plain', |
29 | 29 | realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, 'data', 'testing.1.txt'])), |
30 | - 13, UPLOAD_ERR_OK ); |
|
30 | + 13, UPLOAD_ERR_OK); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | protected function getMockNoFile() |
34 | 34 | { |
35 | 35 | return MockFile::init('foo', 'text0.txt', 'text/plain', |
36 | - '', 26, UPLOAD_ERR_NO_FILE ); |
|
36 | + '', 26, UPLOAD_ERR_NO_FILE); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | public function validate(IValidate $entry): void |
19 | 19 | { |
20 | 20 | $headers = @get_headers(strval($entry->getValue())); |
21 | - if (!empty($headers) && (false !== mb_strpos($headers[0], '200') )) { |
|
21 | + if (!empty($headers) && (false !== mb_strpos($headers[0], '200'))) { |
|
22 | 22 | return; |
23 | 23 | } |
24 | 24 | throw new RuleException(sprintf($this->errorText, $entry->getKey())); |
@@ -38,7 +38,7 @@ |
||
38 | 38 | if (!is_object($singleRule)) { |
39 | 39 | throw new RuleException('Input is not an object.'); |
40 | 40 | } |
41 | - if (! ( ($singleRule instanceof ARule) || ($singleRule instanceof File\AFileRule) ) ) { |
|
41 | + if (!(($singleRule instanceof ARule) || ($singleRule instanceof File\AFileRule))) { |
|
42 | 42 | throw new RuleException(sprintf('Input %s is not instance of ARule or AFileRule.', get_class($singleRule))); |
43 | 43 | } |
44 | 44 | return $singleRule; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | { |
19 | 19 | public function validate(IValidate $entry): void |
20 | 20 | { |
21 | - if (!password_verify( strval($entry->getValue()), strval($this->againstValue) )) { |
|
21 | + if (!password_verify(strval($entry->getValue()), strval($this->againstValue))) { |
|
22 | 22 | throw new RuleException($this->errorText); |
23 | 23 | } |
24 | 24 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | { |
18 | 18 | public function validate(IValidate $entry): void |
19 | 19 | { |
20 | - if (!hash_equals( strval($this->againstValue), strval($entry->getValue()) )) { |
|
20 | + if (!hash_equals(strval($this->againstValue), strval($entry->getValue()))) { |
|
21 | 21 | throw new RuleException($this->errorText); |
22 | 22 | } |
23 | 23 | } |
@@ -52,8 +52,8 @@ |
||
52 | 52 | // IRules::IS_POST_CODE => '\kalanis\kw_rules\Rules\External\IsPostCode', // too many formats for simple check, use regex |
53 | 53 | // IRules::IS_TELEPHONE => '\kalanis\kw_rules\Rules\External\IsPhone', // too many formats for simple check, use regex |
54 | 54 | // IRules::IS_EU_VAT => '\kalanis\kw_rules\Rules\External\IsEuVat', // too many formats, needs some library for checking |
55 | - IRules::IS_DATE => '\kalanis\kw_rules\Rules\External\IsDate', // too many formats, needs some library for checking |
|
56 | - IRules::IS_DATE_REGEX => '\kalanis\kw_rules\Rules\External\IsDateRegex', // too many formats, needs some library for checking |
|
55 | + IRules::IS_DATE => '\kalanis\kw_rules\Rules\External\IsDate', // too many formats, needs some library for checking |
|
56 | + IRules::IS_DATE_REGEX => '\kalanis\kw_rules\Rules\External\IsDateRegex', // too many formats, needs some library for checking |
|
57 | 57 | IRules::SAFE_EQUALS_BASIC => '\kalanis\kw_rules\Rules\Safe\HashedBasicEquals', |
58 | 58 | IRules::SAFE_EQUALS_FUNC => '\kalanis\kw_rules\Rules\Safe\HashedFuncEquals', |
59 | 59 | IRules::SAFE_EQUALS_PASS => '\kalanis\kw_rules\Rules\Safe\HashedPassEquals', |
@@ -26,7 +26,7 @@ |
||
26 | 26 | if (!is_object($againstValue)) { |
27 | 27 | throw new RuleException('Input is not an object.'); |
28 | 28 | } |
29 | - if (! ($againstValue instanceof IValidate) ) { |
|
29 | + if (!($againstValue instanceof IValidate)) { |
|
30 | 30 | throw new RuleException(sprintf('Input %s is not instance of IValidate.', get_class($againstValue))); |
31 | 31 | } |
32 | 32 | return $againstValue; |