| Total Complexity | 6 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 66.67% |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 15 | trait HasAcceptsMediaTrait |
||
| 16 | { |
||
| 17 | /** @var callable */ |
||
| 18 | public $acceptsMedia; |
||
| 19 | |||
| 20 | 16 | protected function initHasAcceptsMedia() |
|
| 28 | } |
||
| 29 | |||
| 30 | 16 | protected function initHasAcceptsMediaWithValidation() |
|
| 31 | { |
||
| 32 | 16 | $this->acceptsMedia(function ($file) { |
|
| 33 | 2 | $validator = $this->getValidator(); |
|
| 34 | 2 | $constraint = $this->getConstraint(); |
|
| 35 | |||
| 36 | 2 | $violations = $validator->validate($file, $constraint); |
|
| 37 | 2 | if ($violations->count() < 1) { |
|
| 38 | 2 | return true; |
|
| 39 | } |
||
| 40 | |||
| 41 | return $violations; |
||
| 42 | 16 | }); |
|
| 43 | 16 | } |
|
| 44 | |||
| 45 | protected function initHasAcceptsMediaEmpty() |
||
| 46 | { |
||
| 47 | $this->acceptsMedia(function () { |
||
| 48 | return true; |
||
| 49 | }); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @param callable $acceptsFile |
||
| 54 | * |
||
| 55 | * @return HasAcceptsMediaTrait |
||
| 56 | */ |
||
| 57 | 16 | public function acceptsMedia(callable $acceptsFile): self |
|
| 62 | } |
||
| 63 | } |
||
| 64 |