|
1
|
|
|
<?php |
|
2
|
|
|
namespace nstdio\svg\animation; |
|
3
|
|
|
|
|
4
|
|
|
use nstdio\svg\attributes\ConditionalProcessing; |
|
5
|
|
|
use nstdio\svg\attributes\ExternalResourcesRequired; |
|
6
|
|
|
use nstdio\svg\attributes\FullyAnimatable; |
|
7
|
|
|
use nstdio\svg\attributes\XLink; |
|
8
|
|
|
use nstdio\svg\ElementInterface; |
|
9
|
|
|
use nstdio\svg\util\KeyValueWriter; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class Animate |
|
13
|
|
|
* The animate element is put inside a shape element and defines how an attribute of an element changes over the |
|
14
|
|
|
* animation. The attribute will change from the initial value to the end value in the duration specified. |
|
15
|
|
|
* |
|
16
|
|
|
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animate |
|
17
|
|
|
* @property int|string repeatCount his attribute indicates the number of time the animation will take place. This |
|
18
|
|
|
* attribute's value specifies the number of iterations. It can include partial iterations expressed as |
|
19
|
|
|
* fraction values. Its value must be greater than 0. Value must be <number> or "indefinite". |
|
20
|
|
|
* |
|
21
|
|
|
* @package nstdio\svg\animation |
|
22
|
|
|
* @author Edgar Asatryan <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class Animate extends BaseAnimation implements FullyAnimatable, XLink, ExternalResourcesRequired, ConditionalProcessing |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Animate constructor. |
|
28
|
|
|
* |
|
29
|
|
|
* @param ElementInterface $parent |
|
30
|
|
|
* @param string $attributeName |
|
31
|
|
|
* @param float $from |
|
32
|
|
|
* @param float $to |
|
33
|
|
|
* @param string $dur |
|
34
|
|
|
* @param string $attributeType |
|
35
|
|
|
* @param int|string $repeatCount |
|
|
|
|
|
|
36
|
|
|
*/ |
|
37
|
2 |
|
public function __construct(ElementInterface $parent, $attributeName, $from, $to, $dur, $attributeType = 'auto', $repeatCount = null) |
|
38
|
|
|
{ |
|
39
|
2 |
|
parent::__construct($parent); |
|
40
|
|
|
|
|
41
|
2 |
|
KeyValueWriter::apply($this->element, [ |
|
42
|
2 |
|
'attributeType' => $attributeType, |
|
43
|
2 |
|
'attributeName' => $attributeName, |
|
44
|
2 |
|
'from' => $from, |
|
45
|
2 |
|
'to' => $to, |
|
46
|
2 |
|
'dur' => $dur, |
|
47
|
2 |
|
'repeatCount' => $repeatCount, |
|
48
|
2 |
|
]); |
|
49
|
2 |
|
} |
|
50
|
|
|
|
|
51
|
2 |
|
public function getName() |
|
52
|
|
|
{ |
|
53
|
2 |
|
return 'animate'; |
|
54
|
|
|
} |
|
55
|
|
|
} |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.