This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from AJenbo/patch-1
- Loading branch information
Showing
5 changed files
with
52 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace byrokrat\checkdigit; | ||
|
||
trait AssertionsTrait | ||
{ | ||
/** | ||
* Validate number sructure, returns number if structure is valid | ||
* | ||
* @throws InvalidStructureException If $number is not numerical | ||
* @return void | ||
*/ | ||
protected function assertNumber(string $number) | ||
{ | ||
if (!ctype_digit($number)) { | ||
throw new InvalidStructureException( | ||
"Number can only contain numerical characters, found <$number>" | ||
); | ||
} | ||
} | ||
} |
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