Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Arguments.php
1<?php
2
4
6{
7 protected Parser $parser;
8 protected array $args;
9
10 public function __construct(Parser $parser, ?array $args = null)
11 {
12 $this->parser = $parser;
13 $this->args = $args ?? [];
14 }
15
16 public function getParser(): Parser
17 {
18 return $this->parser;
19 }
20
21 public function setArgs(array $args): self
22 {
23 $this->args = $args;
24
25 return $this;
26 }
27
28 public function getArray(): array
29 {
30 return $this->args;
31 }
32
33 public function getFlatArray(): array
34 {
35 return \CBPHelper::flatten($this->args);
36 }
37
41 public function getFirst()
42 {
43 return $this->args[0] ?? null;
44 }
45
49 public function getFirstSingle()
50 {
51 return $this->toSingle($this->getFirst());
52 }
53
57 public function getSecond()
58 {
59 return $this->args[1] ?? null;
60 }
61
65 public function getSecondSingle()
66 {
67 return $this->toSingle($this->getSecond());
68 }
69
73 public function getThird()
74 {
75 return $this->args[2] ?? null;
76 }
77
81 public function getThirdSingle()
82 {
83 return $this->toSingle($this->getThird());
84 }
85
89 public function getArg(int $position)
90 {
91 return $this->args[$position] ?? null;
92 }
93
97 public function getArgSingle(int $position)
98 {
99 return $this->toSingle($this->getArg($position));
100 }
101
105 private function toSingle($value)
106 {
107 return is_array($value) ? array_shift($value) : $value;
108 }
109}
__construct(Parser $parser, ?array $args=null)
Definition Arguments.php:10