1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AOE\Crawler\Domain\Model; |
6
|
|
|
|
7
|
|
|
use AOE\Crawler\Exception\NoIndexFoundException; |
8
|
|
|
|
9
|
|
|
/*************************************************************** |
10
|
|
|
* Copyright notice |
11
|
|
|
* |
12
|
|
|
* (c) 2019 AOE GmbH <[email protected]> |
13
|
|
|
* |
14
|
|
|
* All rights reserved |
15
|
|
|
* |
16
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
17
|
|
|
* free software; you can redistribute it and/or modify |
18
|
|
|
* it under the terms of the GNU General Public License as published by |
19
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
20
|
|
|
* (at your option) any later version. |
21
|
|
|
* |
22
|
|
|
* The GNU General Public License can be found at |
23
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
24
|
|
|
* |
25
|
|
|
* This script is distributed in the hope that it will be useful, |
26
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
27
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
28
|
|
|
* GNU General Public License for more details. |
29
|
|
|
* |
30
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
31
|
|
|
***************************************************************/ |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class ProcessCollection |
35
|
|
|
* |
36
|
|
|
* @package AOE\Crawler\Domain\Model |
37
|
|
|
*/ |
38
|
|
|
class ProcessCollection extends \ArrayObject |
39
|
|
|
{ |
40
|
|
|
/** |
41
|
|
|
* Method to retrieve an element from the collection. |
42
|
|
|
* |
43
|
|
|
* @throws NoIndexFoundException |
44
|
|
|
*/ |
45
|
3 |
|
public function offsetGet($index): Process |
46
|
|
|
{ |
47
|
3 |
|
if (! parent::offsetExists($index)) { |
48
|
1 |
|
throw new NoIndexFoundException('Index "' . var_export($index, true) . '" for \AOE\Crawler\Domain\Model\Process are not available'); |
49
|
|
|
} |
50
|
2 |
|
return parent::offsetGet($index); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Method to add an element to the collection- |
55
|
|
|
* |
56
|
|
|
* @param Process $subject |
57
|
|
|
* @throws \InvalidArgumentException |
58
|
|
|
*/ |
59
|
13 |
|
public function offsetSet($index, $subject): void |
60
|
|
|
{ |
61
|
13 |
|
if (! $subject instanceof Process) { |
|
|
|
|
62
|
1 |
|
throw new \InvalidArgumentException('Wrong parameter type given, "\AOE\Crawler\Domain\Model\Process" expected!'); |
63
|
|
|
} |
64
|
|
|
|
65
|
12 |
|
parent::offsetSet($index, $subject); |
66
|
12 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Method to append an element to the collection |
70
|
|
|
* @param Process $subject |
71
|
|
|
* @throws \InvalidArgumentException |
72
|
|
|
*/ |
73
|
12 |
|
public function append($subject): void |
74
|
|
|
{ |
75
|
12 |
|
if (! $subject instanceof Process) { |
|
|
|
|
76
|
1 |
|
throw new \InvalidArgumentException('Wrong parameter type given, "\AOE\Crawler\Domain\Model\Process" expected!'); |
77
|
|
|
} |
78
|
|
|
|
79
|
11 |
|
parent::append($subject); |
80
|
11 |
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* returns array of process ids of the current collection |
84
|
|
|
* @return array |
85
|
|
|
*/ |
86
|
1 |
|
public function getProcessIds() |
87
|
|
|
{ |
88
|
1 |
|
$result = []; |
89
|
1 |
|
foreach ($this->getIterator() as $value) { |
90
|
1 |
|
$result[] = $value->getProcessId(); |
91
|
|
|
} |
92
|
1 |
|
return $result; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|