-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Those methods can be handy in a variety of scenarios. Hence I decided to implement them. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
- Loading branch information
1 parent
d340b7a
commit 557a4fb
Showing
23 changed files
with
983 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Respect/Assertion. | ||
* | ||
* (c) Henrique Moody <henriquemoody@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Respect\Assertion\Chain; | ||
|
||
use Respect\Assertion\Creator; | ||
use Respect\Assertion\Mixin\Chain\Mixin; | ||
use Throwable; | ||
|
||
/** | ||
* @mixin Mixin | ||
*/ | ||
final class AssociativeFullChain extends FullChain | ||
{ | ||
public function __construct( | ||
Creator $creator, | ||
int|string $reference, | ||
mixed $input, | ||
null|string|Throwable $description, | ||
string $prefix = '' | ||
) { | ||
parent::__construct($creator, $input, $description, $prefix, $reference); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Respect/Assertion. | ||
* | ||
* (c) Henrique Moody <henriquemoody@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Respect\Assertion\Chain; | ||
|
||
use Respect\Assertion\Creator; | ||
use Respect\Assertion\Mixin\Chain\Mixin; | ||
use Throwable; | ||
|
||
/** | ||
* @mixin Mixin | ||
*/ | ||
final class AssociativeSimpleChain extends SimpleChain | ||
{ | ||
public function __construct( | ||
Creator $creator, | ||
int|string $reference, | ||
mixed $input, | ||
null|string|Throwable $description, | ||
string $prefix | ||
) { | ||
parent::__construct($creator, $input, $description, $prefix, $reference); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Respect/Assertion. | ||
* | ||
* (c) Henrique Moody <henriquemoody@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Respect\Assertion\Chain; | ||
|
||
use Throwable; | ||
|
||
abstract class FullChain extends SimpleChain | ||
{ | ||
public function all(null|string|Throwable $description = null): RegularFullChain | ||
{ | ||
return new RegularFullChain($this->creator, $this->input, $description, 'all'); | ||
} | ||
|
||
public function not(null|string|Throwable $description = null): RegularFullChain | ||
{ | ||
return new RegularFullChain($this->creator, $this->input, $description, 'not'); | ||
} | ||
|
||
public function nullOr(null|string|Throwable $description = null): RegularFullChain | ||
{ | ||
return new RegularFullChain($this->creator, $this->input, $description, 'nullOr'); | ||
} | ||
|
||
public function key(string $key, null|string|Throwable $description = null): AssociativeFullChain | ||
{ | ||
return new AssociativeFullChain($this->creator, $key, $this->input, $description, 'key'); | ||
} | ||
|
||
public function property(string $key, null|string|Throwable $description = null): AssociativeFullChain | ||
{ | ||
return new AssociativeFullChain($this->creator, $key, $this->input, $description, 'property'); | ||
} | ||
} |
Oops, something went wrong.