Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
componentscollection.php
1
<?php
2
3
4
namespace
Bitrix\Calendar\ICal\Parser
;
5
6
7
use ArrayIterator;
8
use IteratorAggregate;
9
use LogicException;
10
11
class
ComponentsCollection
implements
IteratorAggregate
12
{
16
private
$collection;
17
22
public
static
function
createInstance
(array $collection =
null
):
ComponentsCollection
23
{
24
return
new
self
($collection);
25
}
26
31
public
function
__construct
(array $collection =
null
)
32
{
33
if
(!$this->checkCollection($collection))
34
{
35
throw
new
LogicException
(
'The collection contains elements of the wrong class. You need to pass a collection of objects Bitrix\\Calendar\\ICal\\Builder\\Attendee'
);
36
}
37
38
$this->collection = $collection ?? [];
39
}
40
44
public
function
getIterator
(): ArrayIterator
45
{
46
return
new
ArrayIterator($this->collection);
47
}
48
53
public
function
add
(?
ParserComponent
$component):
ComponentsCollection
54
{
55
if
($component ===
null
)
56
{
57
return
$this;
58
}
59
60
$this->collection[] = $component;
61
62
return
$this;
63
}
64
68
public
function
count
(): int
69
{
70
return
count
($this->collection);
71
}
72
76
public
function
hasOneComponent
(): bool
77
{
78
return
$this->
count
() === 1;
79
}
80
84
public
function
hasOneCalendarComponent
(): bool
85
{
86
return
$this->
hasOneComponent
() && ($this->collection[0] instanceof
Calendar
);
87
}
88
93
private
function
checkCollection(?array $collection): bool
94
{
95
if
($collection ===
null
)
96
{
97
return
true
;
98
}
99
100
$attendee = array_filter($collection,
function
($attendee) {
101
return
!($attendee instanceof ParserComponent);
102
});
103
104
return
empty($attendee);
105
}
106
}
Bitrix\Calendar\ICal\Parser\Calendar
Definition
calendar.php:8
Bitrix\Calendar\ICal\Parser\ComponentsCollection
Definition
componentscollection.php:12
Bitrix\Calendar\ICal\Parser\ComponentsCollection\createInstance
static createInstance(array $collection=null)
Definition
componentscollection.php:22
Bitrix\Calendar\ICal\Parser\ComponentsCollection\add
add(?ParserComponent $component)
Definition
componentscollection.php:53
Bitrix\Calendar\ICal\Parser\ComponentsCollection\hasOneCalendarComponent
hasOneCalendarComponent()
Definition
componentscollection.php:84
Bitrix\Calendar\ICal\Parser\ComponentsCollection\getIterator
getIterator()
Definition
componentscollection.php:44
Bitrix\Calendar\ICal\Parser\ComponentsCollection\hasOneComponent
hasOneComponent()
Definition
componentscollection.php:76
Bitrix\Calendar\ICal\Parser\ComponentsCollection\__construct
__construct(array $collection=null)
Definition
componentscollection.php:31
Bitrix\Calendar\ICal\Parser\ComponentsCollection\count
count()
Definition
componentscollection.php:68
Bitrix\Calendar\ICal\Parser\ParserComponent
Definition
parsercomponent.php:10
Bitrix\Security\LogicException
Definition
logicexception.php:22
Bitrix\Calendar\ICal\Parser
Definition
calendar.php:4
modules
calendar
lib
ical
parser
componentscollection.php
Создано системой
1.10.0