| Total Complexity | 5 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 12 | class GenericCheck implements FluentCheck |
||
| 13 | { |
||
| 14 | 1 | use TypeCheck, FluentChecks, ConstraintCheck, WithMessage; |
|
| 15 | |||
| 16 | /** |
||
| 17 | * @var mixed |
||
| 18 | */ |
||
| 19 | private $value; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * GenericCheck constructor. |
||
| 23 | * |
||
| 24 | * @param mixed $value |
||
| 25 | */ |
||
| 26 | 133 | public function __construct($value) |
|
| 27 | { |
||
| 28 | 133 | $this->value = $value; |
|
| 29 | 133 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @param mixed $expected |
||
| 33 | * |
||
| 34 | * @return GenericCheck |
||
| 35 | */ |
||
| 36 | 34 | public function isEqualTo($expected): self |
|
| 37 | { |
||
| 38 | 34 | Assert::assertSame($expected, $this->value, $this->message); |
|
| 39 | 34 | $this->resetMessage(); |
|
| 40 | 34 | return $this; |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param mixed $expected |
||
| 45 | * |
||
| 46 | * @return GenericCheck |
||
| 47 | */ |
||
| 48 | 2 | public function isNotEqualTo($expected): self |
|
| 53 | } |
||
| 54 | |||
| 55 | 2 | public function isEmpty(): self |
|
| 56 | { |
||
| 57 | 2 | Assert::assertEmpty($this->value, $this->message); |
|
| 58 | 2 | $this->resetMessage(); |
|
| 59 | 2 | return $this; |
|
| 60 | } |
||
| 61 | |||
| 62 | 1 | public function isNotEmpty(): self |
|
| 67 | } |
||
| 68 | } |
||
| 69 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: