pitchart /
phlunit
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | |||
| 4 | namespace Pitchart\Phlunit\Checks; |
||
| 5 | |||
| 6 | use PHPUnit\Framework\Assert; |
||
| 7 | use Pitchart\Phlunit\Checks\Mixin\ConstraintCheck; |
||
| 8 | use Pitchart\Phlunit\Checks\Mixin\FluentChecks; |
||
| 9 | use Pitchart\Phlunit\Checks\Mixin\TypeCheck; |
||
|
0 ignored issues
–
show
|
|||
| 10 | use Pitchart\Phlunit\Checks\Mixin\WithMessage; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Class BooleanCheck |
||
| 14 | * |
||
| 15 | * @package Pitchart\Phlunit\Checks |
||
| 16 | * |
||
| 17 | * @author Julien VITTE <[email protected]> |
||
| 18 | * |
||
| 19 | * @implements FluentCheck<boolean> |
||
| 20 | */ |
||
| 21 | class BooleanCheck implements FluentCheck |
||
| 22 | { |
||
| 23 | 1 | use TypeCheck, FluentChecks, WithMessage, ConstraintCheck; |
|
| 24 | |||
| 25 | /** |
||
| 26 | * @var mixed |
||
| 27 | */ |
||
| 28 | private $value; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * BooleanCheck constructor. |
||
| 32 | * |
||
| 33 | * @param bool $value |
||
| 34 | */ |
||
| 35 | 144 | public function __construct(bool $value) |
|
| 36 | { |
||
| 37 | 144 | $this->value = $value; |
|
| 38 | 144 | } |
|
| 39 | |||
| 40 | 95 | public function isTrue(): self |
|
| 41 | { |
||
| 42 | 95 | Assert::assertTrue($this->value); |
|
| 43 | 95 | return $this; |
|
| 44 | } |
||
| 45 | |||
| 46 | 43 | public function isFalse(): self |
|
| 47 | { |
||
| 48 | 43 | Assert::assertFalse($this->value); |
|
| 49 | 43 | return $this; |
|
| 50 | } |
||
| 51 | } |
||
| 52 |
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: