henryejemuta /
laravel-monnify
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Created By: Henry Ejemuta |
||
| 4 | * Project: laravel-monnify |
||
| 5 | * Class Name: MonnifyOnFailureValidate.php |
||
| 6 | * Date Created: 7/15/20 |
||
| 7 | * Time Created: 8:06 AM |
||
| 8 | */ |
||
| 9 | |||
| 10 | namespace HenryEjemuta\LaravelMonnify\Classes; |
||
| 11 | |||
| 12 | |||
| 13 | class MonnifyOnFailureValidate |
||
| 14 | { |
||
| 15 | private $onFailureValidate; |
||
| 16 | |||
| 17 | private static $cache = []; |
||
| 18 | private const BREAK = "BREAK"; |
||
| 19 | private const CONTINUE = "CONTINUE"; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * MonnifyOnFailureValidate constructor. |
||
| 23 | * @param string $onFailureValidate |
||
| 24 | */ |
||
| 25 | private function __construct(string $onFailureValidate) |
||
| 26 | { |
||
| 27 | $this->onFailureValidate = $onFailureValidate; |
||
| 28 | } |
||
| 29 | |||
| 30 | public static function BREAK(): MonnifyOnFailureValidate |
||
| 31 | { |
||
| 32 | if (!key_exists(self::BREAK, self::$cache)) |
||
| 33 | self::$cache[self::BREAK] = new MonnifyOnFailureValidate( self::BREAK); |
||
| 34 | return self::$cache[self::BREAK]; |
||
| 35 | } |
||
| 36 | |||
| 37 | public static function CONTINUE(): MonnifyOnFailureValidate |
||
| 38 | { |
||
| 39 | if (!key_exists(self::CONTINUE, self::$cache)) |
||
| 40 | self::$cache[self::CONTINUE] = new MonnifyOnFailureValidate( self::CONTINUE); |
||
| 41 | return self::$cache[self::CONTINUE]; |
||
| 42 | } |
||
| 43 | |||
| 44 | public static function findOnFailureValidate(string $onFailureValidate): MonnifyOnFailureValidate |
||
| 45 | { |
||
| 46 | switch (strtoupper($onFailureValidate)) { |
||
| 47 | case self::BREAK: |
||
| 48 | return self::BREAK(); |
||
| 49 | case self::CONTINUE: |
||
| 50 | return self::CONTINUE(); |
||
| 51 | default: |
||
| 52 | return null; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | public function __toString(): string |
||
| 57 | { |
||
| 58 | return $this->onFailureValidate; |
||
| 59 | } |
||
| 60 | |||
| 61 | } |
||
| 62 |