| Total Complexity | 3 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Arcanesoft\Media\Rules; |
||
| 12 | class MediaItemUniqueRule implements Rule |
||
| 13 | { |
||
| 14 | /* ----------------------------------------------------------------- |
||
| 15 | | Properties |
||
| 16 | | ----------------------------------------------------------------- |
||
| 17 | */ |
||
| 18 | |||
| 19 | /** @var \Arcanesoft\Media\MediaManager */ |
||
| 20 | protected $manager; |
||
| 21 | |||
| 22 | /* ----------------------------------------------------------------- |
||
| 23 | | Constructor |
||
| 24 | | ----------------------------------------------------------------- |
||
| 25 | */ |
||
| 26 | |||
| 27 | public function __construct(MediaManager $manager) |
||
| 28 | { |
||
| 29 | $this->manager = $manager; |
||
| 30 | } |
||
| 31 | |||
| 32 | /* ----------------------------------------------------------------- |
||
| 33 | | Main Methods |
||
| 34 | | ----------------------------------------------------------------- |
||
| 35 | */ |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Determine if the validation rule passes. |
||
| 39 | * |
||
| 40 | * @param string $attribute |
||
| 41 | * @param mixed $value |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public function passes($attribute, $value) |
||
| 46 | { |
||
| 47 | return ! $this->manager->exists($value); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Get the validation error message. |
||
| 52 | * |
||
| 53 | * @return string|array |
||
| 54 | */ |
||
| 55 | public function message() |
||
| 58 | } |
||
| 59 | } |
||
| 60 |