Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
attendeescollection.php
1
<?php
2
3
4
namespace
Bitrix\Calendar\ICal\Builder
;
5
6
7
use Bitrix\Calendar\SerializeObject;
8
use ArrayIterator;
9
use IteratorAggregate;
10
use Serializable;
11
16
class
AttendeesCollection
implements
IteratorAggregate, Serializable
17
{
18
use SerializeObject;
22
private
array $collection;
23
28
public
static
function
createInstance
(array $collection = []):
AttendeesCollection
29
{
30
return
new
self
($collection);
31
}
32
33
38
public
function
__construct
(array $collection = [])
39
{
40
if
(!$this->checkCollection($collection))
41
{
42
throw
new \InvalidArgumentException(
'The collection contains elements of the wrong class. You need to pass a collection of objects Bitrix\\Calendar\\ICal\\Builder\\Attendee'
);
43
}
44
45
$this->collection = $collection;
46
}
47
51
public
function
__toString
(): string
52
{
53
if
(empty($this->collection))
54
{
55
return
''
;
56
}
57
58
$result = [];
59
foreach
($this->collection as $attendee)
60
{
61
if
(!empty($attendee->getFullName()))
62
{
63
$result[] = $attendee->getFullName();
64
}
65
}
66
67
return
implode(
', '
, $result);
68
}
69
74
public
function
add
(
Attendee
$attendee):
AttendeesCollection
75
{
76
$this->collection[] = $attendee;
77
78
return
$this;
79
}
80
84
public
function
getIterator
(): ArrayIterator
85
{
86
return
new
ArrayIterator($this->collection);
87
}
88
92
public
function
getCount
(): int
93
{
94
return
count($this->collection);
95
}
96
101
private
function
checkCollection(?array $collection): bool
102
{
103
if
(is_null($collection))
104
{
105
return
true
;
106
}
107
108
$attendee = array_filter($collection,
static
function
($attendee) {
109
return
!($attendee instanceof
Attendee
);
110
});
111
112
return
empty($attendee);
113
}
114
}
Bitrix\Calendar\ICal\Builder\Attendee
Definition
attendee.php:11
Bitrix\Calendar\ICal\Builder\AttendeesCollection
Definition
attendeescollection.php:17
Bitrix\Calendar\ICal\Builder\AttendeesCollection\add
add(Attendee $attendee)
Definition
attendeescollection.php:74
Bitrix\Calendar\ICal\Builder\AttendeesCollection\getCount
getCount()
Definition
attendeescollection.php:92
Bitrix\Calendar\ICal\Builder\AttendeesCollection\__construct
__construct(array $collection=[])
Definition
attendeescollection.php:38
Bitrix\Calendar\ICal\Builder\AttendeesCollection\__toString
__toString()
Definition
attendeescollection.php:51
Bitrix\Calendar\ICal\Builder\AttendeesCollection\getIterator
getIterator()
Definition
attendeescollection.php:84
Bitrix\Calendar\ICal\Builder\AttendeesCollection\createInstance
static createInstance(array $collection=[])
Definition
attendeescollection.php:28
Bitrix\Calendar\ICal\Builder
Definition
alert.php:4
modules
calendar
lib
ical
builder
attendeescollection.php
Создано системой
1.10.0