| Total Complexity | 11 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class UniqueBlockerItemValueEmail implements Rule |
||
| 9 | { |
||
| 10 | private $typeId; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Create a new rule instance. |
||
| 14 | * |
||
| 15 | * @return void |
||
| 16 | */ |
||
| 17 | public function __construct($typeId) |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Determine if the validation rule passes. |
||
| 24 | * |
||
| 25 | * @param string $attribute |
||
| 26 | * @param mixed $value |
||
| 27 | * |
||
| 28 | * @return bool |
||
| 29 | */ |
||
| 30 | public function passes($attribute, $value) |
||
| 31 | { |
||
| 32 | if ($this->typeId) { |
||
| 33 | $type = BlockedType::find($this->typeId); |
||
| 34 | |||
| 35 | if ($type->slug == 'email' || $type->slug == 'user') { |
||
| 36 | $check = $this->checkEmail($value); |
||
| 37 | |||
| 38 | if ($check) { |
||
| 39 | return $value; |
||
| 40 | } |
||
| 41 | |||
| 42 | return false; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | return true; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Check if value is proper formed email. |
||
| 51 | * |
||
| 52 | * @param string $email The email |
||
| 53 | * |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | public function checkEmail($email) |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get the validation error message. |
||
| 66 | * |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | public function message() |
||
| 74 |