scratch – Blame information for rev 115
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
115 | office | 1 | <?php |
2 | |||
3 | /* |
||
4 | * This file is part of PHP-FFmpeg. |
||
5 | * |
||
6 | * (c) Alchemy <info@alchemy.fr> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace FFMpeg\FFProbe\DataMapping; |
||
13 | |||
14 | abstract class AbstractData implements \Countable |
||
15 | { |
||
16 | private $properties; |
||
17 | |||
18 | public function __construct(array $properties) |
||
19 | { |
||
20 | $this->properties = $properties; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Returns true if data has property. |
||
25 | * |
||
26 | * @param string $property |
||
27 | * @return Boolean |
||
28 | */ |
||
29 | public function has($property) |
||
30 | { |
||
31 | return isset($this->properties[$property]); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Returns the property value given its name. |
||
36 | * |
||
37 | * @param string $property |
||
38 | * @param mixed $default |
||
39 | * |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function get($property, $default = null) |
||
43 | { |
||
44 | if (!isset($this->properties[$property])) { |
||
45 | return $default; |
||
46 | } |
||
47 | |||
48 | return $this->properties[$property]; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Sets the property value given its name. |
||
53 | * |
||
54 | * @param string $property |
||
55 | * @param mixed $value |
||
56 | * |
||
57 | * @return AbstractData |
||
58 | */ |
||
59 | public function set($property, $value) |
||
60 | { |
||
61 | $this->properties[$property] = $value; |
||
62 | |||
63 | return $this; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Returns all property names. |
||
68 | * |
||
69 | * @return array |
||
70 | */ |
||
71 | public function keys() |
||
72 | { |
||
73 | return array_keys($this->properties); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Returns all properties and their values. |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function all() |
||
82 | { |
||
83 | return $this->properties; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function count() |
||
90 | { |
||
91 | return count($this->properties); |
||
92 | } |
||
93 | } |