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