Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
propertytype.php
1<?php
2
3
5
6
7abstract class PropertyType
8{
9 protected $names;
10 protected $parameters = [];
11
12 abstract public function getValue(): string;
13
14 abstract public function getOriginalValue();
15
16 public function __construct($names)
17 {
18 $this->names = is_string($names)
19 ? [$names]
20 : $names;
21 }
22
23 public function getNames(): array
24 {
25 return $this->names;
26 }
27
28 public function getParameters(): array
29 {
30 return $this->parameters;
31 }
32
33 public function getParameter(string $name): Parameter
34 {
35 $parameters = array_values(array_filter(
36 $this->parameters,
37 function (Parameter $property) use ($name) {
38 return $property->getName() === $name;
39 }
40 ));
41
42 return $parameters[0];
43 }
44
45 public function addParameters(array $parameters): PropertyType
46 {
47 foreach ($parameters as $parameter) {
48 $this->addParameter($parameter);
49 }
50
51 return $this;
52 }
53
54 public function addParameter(Parameter $parameter): PropertyType
55 {
56 $this->parameters[] = $parameter;
57
58 return $this;
59 }
60}