| Total Complexity | 6 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class StartsWithUo implements Rule |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Create a new rule instance. |
||
| 11 | * |
||
| 12 | * @return void |
||
| 13 | */ |
||
| 14 | public function __construct() |
||
| 15 | { |
||
| 16 | // |
||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Determine if the validation rule passes. |
||
| 21 | * |
||
| 22 | * @param string $attribute |
||
| 23 | * @param mixed $value |
||
| 24 | * @return bool |
||
| 25 | */ |
||
| 26 | public function passes($attribute, $value) |
||
| 27 | { |
||
| 28 | if (!isset($this->data['thing']) || ($this->data['thing'] != '1')) { // Ikke bibsys-dok: |
||
|
|
|||
| 29 | return true; |
||
| 30 | } |
||
| 31 | if (!preg_match('/[0-9]/', $value)) { // Inneholder ikke tall: antakelig et navn |
||
| 32 | return true; |
||
| 33 | } |
||
| 34 | return substr($value, 0, 2) == 'uo'; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Get the validation error message. |
||
| 39 | * |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public function message() |
||
| 45 | } |
||
| 46 | } |
||
| 47 |