Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
propertycreator.php
1<?php
2
3
5
6
8{
9 private $property;
10
11 public function __construct(PropertyType $property)
12 {
13 $this->property = $property;
14 }
15
16 public function build(): array
17 {
18 $parameters = $this->resolveParameters();
19
20 $value = $this->property->getValue();
21
22 return array_map(function (string $name) use ($value, $parameters)
23 {
24 if ($value === '' && $parameters === '')
25 {
26 return "{$name}:";
27 }
28
29 if ($value === '')
30 {
31 if ($name === 'RRULE')
32 {
33 $parameters = substr_replace($parameters, ':',0, 1);
34 }
35
36 return "{$name}{$parameters}";
37 }
38
39 return "{$name}{$parameters}:{$value}";
40 }, $this->property->getNames());
41 }
42
43 private function resolveParameters(): string
44 {
45 $parameters = '';
46
47 foreach ($this->property->getParameters() as $parameter)
48 {
49 $name = $parameter->getName();
50 $value = $parameter->getValue();
51
52 $parameters .= ";{$name}={$value}";
53 }
54
55 return $parameters;
56 }
57}