Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
72.73% |
8 / 11 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Image | |
72.73% |
8 / 11 |
|
66.67% |
2 / 3 |
7.99 | |
0.00% |
0 / 1 |
| supportedTranslateModes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| value | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
| structure | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Field; |
| 6 | |
| 7 | use Cosray\Schema\TranslateMode; |
| 8 | use Cosray\Value; |
| 9 | |
| 10 | class Image extends File |
| 11 | { |
| 12 | /** @return list<TranslateMode> */ |
| 13 | protected function supportedTranslateModes(): array |
| 14 | { |
| 15 | return [TranslateMode::Symmetric, TranslateMode::Asymmetric]; |
| 16 | } |
| 17 | |
| 18 | public function value(): Value\Images|Value\Image |
| 19 | { |
| 20 | if ($this->allowsMultipleItems()) { |
| 21 | if ($this->isAsymmetricallyTranslated()) { |
| 22 | return new Value\TranslatedImages($this->owner, $this, $this->valueContext); |
| 23 | } |
| 24 | |
| 25 | return new Value\Images($this->owner, $this, $this->valueContext); |
| 26 | } |
| 27 | |
| 28 | if ($this->isAsymmetricallyTranslated()) { |
| 29 | return new Value\TranslatedImage($this->owner, $this, $this->valueContext); |
| 30 | } |
| 31 | |
| 32 | return new Value\Image($this->owner, $this, $this->valueContext); |
| 33 | } |
| 34 | |
| 35 | public function structure(mixed $value = null): array |
| 36 | { |
| 37 | if ($this->isAsymmetricallyTranslated()) { |
| 38 | return $this->getTranslatableFileStructure('image', $value); |
| 39 | } |
| 40 | |
| 41 | return $this->getFileStructure('image', $value); |
| 42 | } |
| 43 | } |