1 | <?php |
||
72 | class Pattern extends Container implements TransformInterface, Transformable |
||
73 | { |
||
74 | use TransformTrait; |
||
75 | |||
76 | 9 | public function __construct(ElementInterface $parent, $id = null) |
|
87 | |||
88 | 9 | public function getName() |
|
92 | |||
93 | 1 | public static function withShape(ContainerInterface $container, Shape $shape, array $patternConfig = [], $id = null) |
|
94 | { |
||
95 | 1 | $patternConfig = array_merge(self::getDefaultConfig(), $patternConfig); |
|
96 | |||
97 | 1 | $shapeBox = $shape->getBoundingBox(); |
|
98 | 1 | $patternConfig['width'] = $shapeBox['width']; |
|
99 | 1 | $patternConfig['height'] = $shapeBox['height']; |
|
100 | |||
101 | 1 | $pattern = (new self($container, $id))->apply($patternConfig); |
|
102 | 1 | $shape->getRoot()->removeChild($shape); |
|
|
|||
103 | 1 | $pattern->append($shape); |
|
104 | |||
105 | 1 | return $pattern; |
|
106 | } |
||
107 | |||
108 | 1 | public static function verticalHatch(ContainerInterface $container, array $patternConfig = [], array $lineConfig = [], $id = null) |
|
109 | { |
||
110 | 1 | return self::hatch($container, $patternConfig, $lineConfig, $id); |
|
111 | } |
||
112 | |||
113 | 1 | public static function horizontalHatch(ContainerInterface $container, array $patternConfig = [], array $lineConfig = [], $id = null) |
|
114 | { |
||
115 | 1 | return self::hatch($container, $patternConfig, $lineConfig, $id)->rotate(90); |
|
116 | } |
||
117 | |||
118 | 3 | public static function diagonalHatch(ContainerInterface $container, array $patternConfig = [], array $lineConfig = [], $id = null) |
|
119 | { |
||
120 | 3 | return self::hatch($container, $patternConfig, $lineConfig, $id)->rotate(45); |
|
121 | } |
||
122 | |||
123 | 2 | public static function crossHatch(ContainerInterface $container, array $patternConfig = [], array $lineConfig = [], $id = null) |
|
124 | { |
||
125 | 2 | if (isset($patternConfig['width'])) { |
|
126 | 2 | $patternConfig['height'] = $patternConfig['width']; |
|
127 | 2 | } |
|
128 | 2 | if (isset($patternConfig['height'])) { |
|
129 | 2 | $patternConfig['width'] = $patternConfig['height']; |
|
130 | 2 | } |
|
131 | |||
132 | /** @var Pattern $pattern */ |
||
133 | 2 | $pattern = self::diagonalHatch($container, $patternConfig, $lineConfig, $id); |
|
134 | |||
135 | /** @var Line $firstLine */ |
||
136 | 2 | $firstLine = $pattern->getFirstChild()->apply([ |
|
137 | 2 | 'x1' => 0, |
|
138 | 2 | 'y1' => $pattern->height / 2, |
|
139 | 2 | 'x2' => $pattern->width, |
|
140 | 2 | 'y2' => $pattern->height / 2, |
|
141 | 2 | ]); |
|
142 | |||
143 | 2 | $attrs = $firstLine->allAttributes(['x1', 'y1', 'x2', 'y2', 'id']); |
|
144 | 2 | $line = new Line($pattern, $pattern->width / 2, 0, $pattern->width / 2, $pattern->height); |
|
145 | 2 | $line->id = null; |
|
146 | 2 | $line->apply($attrs); |
|
147 | |||
148 | 2 | return $pattern; |
|
149 | } |
||
150 | |||
151 | 1 | public static function straightCrossHatch(ContainerInterface $container, array $patternConfig = [], array $lineConfig = [], $id = null) |
|
152 | { |
||
153 | 1 | return self::crossHatch($container, $patternConfig, $lineConfig, $id)->rotate(90); |
|
154 | } |
||
155 | |||
156 | 5 | protected static function hatch(ContainerInterface $container, array $patternConfig = [], array $lineConfig = [], $id = null) |
|
157 | { |
||
158 | 5 | $patternConfig = array_merge(self::getDefaultConfig(), $patternConfig); |
|
159 | 5 | $lineDefaultConfig = ['stroke' => 'black', 'stroke-width' => 1, 'fill' => 'none']; |
|
160 | 5 | $lineConfig = array_merge($lineDefaultConfig, $lineConfig); |
|
161 | |||
162 | 5 | $pattern = (new self($container, $id))->apply($patternConfig); |
|
163 | |||
164 | 5 | (new Line($pattern, 0, 0, 0, $pattern->height))->apply($lineConfig); |
|
165 | |||
166 | 5 | return $pattern; |
|
167 | } |
||
168 | |||
169 | 6 | protected static function getDefaultConfig() |
|
170 | { |
||
171 | 6 | return ['x' => 0, 'y' => 0, 'height' => 4, 'width' => 4, 'patternUnits' => 'userSpaceOnUse']; |
|
172 | } |
||
173 | |||
174 | /** |
||
175 | * @inheritdoc |
||
176 | */ |
||
177 | 9 | public function getTransformAttribute() |
|
181 | |||
182 | /** |
||
183 | * @inheritdoc |
||
184 | */ |
||
185 | 5 | public function setTransformAttribute($transformList) |
|
186 | { |
||
187 | 5 | $this->patternTransform = $transformList; |
|
188 | } |
||
189 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.