Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
StringRule | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
testConditions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
exceptionMessageOnTestFailure | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace WsdlToPhp\PackageGenerator\File\Validation; |
6 | |
7 | final class StringRule extends AbstractRule |
8 | { |
9 | public function name(): string |
10 | { |
11 | return 'string'; |
12 | } |
13 | |
14 | public function testConditions(string $parameterName, $value, bool $itemType = false): string |
15 | { |
16 | return sprintf(($itemType ? '' : '!is_null($%1$s) && ').'!is_string($%1$s)', $parameterName); |
17 | } |
18 | |
19 | public function exceptionMessageOnTestFailure(string $parameterName, $value, bool $itemType = false): string |
20 | { |
21 | return sprintf('sprintf(\'Invalid value %%s, please provide a string, %%s given\', var_export($%1$s, true), gettype($%1$s))', $parameterName); |
22 | } |
23 | } |