Completed
Pull Request — develop (#359)
by Mathias
23:51
created

ImageSetOptions::getEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2017 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Core\Options;
12
13
use Core\Entity\Image;
14
use Core\Entity\ImageSetInterface;
15
use Zend\Stdlib\AbstractOptions;
16
17
/**
18
 * Options for configuring ImageSetHydrator instances.
19
 * 
20
 * @author Mathias Gelhausen <[email protected]>
21
 * @since 0,29
22
 */
23
class ImageSetOptions extends AbstractOptions
24
{
25
26
    /**
27
     * Entity class for images.
28
     *
29
     * @var string
30
     */
31
    protected $entityClass = Image::class;
32
33
    /**
34
     * Name of the form element.
35
     *
36
     * @var string
37
     */
38
    protected $formElementName = ImageSetInterface::ORIGINAL;
39
40
    /**
41
     * Image specifications.
42
     *
43
     * @var array
44
     */
45
    protected $images = [
46
        ImageSetInterface::THUMBNAIL => [100,100],
47
    ];
48
49
    /**
50
     * @param string $entityClass
51
     *
52
     * @return self
53
     */
54
    public function setEntityClass($entityClass)
55
    {
56
        $this->entityClass = $entityClass;
57
58
        return $this;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getEntityClass()
65
    {
66
        return $this->entityClass;
67
    }
68
69
    /**
70
     * @return \Core\Entity\ImageInterface
71
     */
72
    public function getEntity()
73
    {
74
        $class = $this->getEntityClass();
75
76
        return new $class();
77
    }
78
79
    /**
80
     * @param string $formElementName
81
     *
82
     * @return self
83
     */
84
    public function setFormElementName($formElementName)
85
    {
86
        $this->formElementName = $formElementName;
87
88
        return $this;
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function getFormElementName()
95
    {
96
        return $this->formElementName;
97
    }
98
99
    /**
100
     * Set image specifications.
101
     *
102
     * <pre>
103
     * [
104
     *      <imageKey> => [<maxWidth>,<maxHeight>],
105
     * ]
106
     * </pre>
107
     *
108
     * @param array $images
109
     *
110
     * @return self
111
     */
112
    public function setImages($images)
113
    {
114
        $this->images = $images;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return array
121
     */
122
    public function getImages()
123
    {
124
        return $this->images;
125
    }
126
}