Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
warning.php
1<?php
2
3namespace Bitrix\Translate;
4
6
11{
13 protected $warningCollection;
14
22 final public function addWarning(Main\Error $error): self
23 {
24 if (!$this->warningCollection instanceof Main\ErrorCollection)
25 {
26 $this->warningCollection = new Main\ErrorCollection;
27 }
28
29 $this->warningCollection[] = $error;
30
31 return $this;
32 }
33
39 final public function getWarnings(): array
40 {
41 if (!$this->warningCollection instanceof Main\ErrorCollection)
42 {
43 return array();
44 }
45
46 return $this->warningCollection->toArray();
47 }
48
54 final public function hasWarnings(): bool
55 {
56 if (!$this->warningCollection instanceof Main\ErrorCollection)
57 {
58 return false;
59 }
60
61 return !$this->warningCollection->isEmpty();
62 }
63
69 final public function getLastWarning(): ?Main\Error
70 {
71 if (!$this->warningCollection instanceof Main\ErrorCollection)
72 {
73 return null;
74 }
75 if (!$this->hasWarnings())
76 {
77 return null;
78 }
79
80 $offset = $this->warningCollection->count() - 1;
81
82 return $this->warningCollection->offsetGet($offset);
83 }
84
90 final public function getFirstWarning(): ?Main\Error
91 {
92 if (!$this->warningCollection instanceof Main\ErrorCollection)
93 {
94 return null;
95 }
96 if (!$this->hasWarnings())
97 {
98 return null;
99 }
100
101 return $this->warningCollection->offsetGet(0);
102 }
103}
addWarning(Main\Error $error)
Definition warning.php:22