|
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
|
|
|
public function offsetGet($index): Process |
|
46
|
|
|
{ |
|
47
|
|
|
if (! parent::offsetExists($index)) { |
|
48
|
|
|
throw new NoIndexFoundException('Index "' . var_export($index, true) . '" for \AOE\Crawler\Domain\Model\Process are not available', 1593714823); |
|
49
|
|
|
} |
|
50
|
|
|
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
|
20 |
|
public function offsetSet($index, $subject): void |
|
60
|
|
|
{ |
|
61
|
20 |
|
if (! $subject instanceof Process) { |
|
|
|
|
|
|
62
|
|
|
throw new \InvalidArgumentException('Wrong parameter type given, "\AOE\Crawler\Domain\Model\Process" expected!', 1593714822); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
20 |
|
parent::offsetSet($index, $subject); |
|
66
|
20 |
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Method to append an element to the collection |
|
70
|
|
|
* @param Process $subject |
|
71
|
|
|
* @throws \InvalidArgumentException |
|
72
|
|
|
*/ |
|
73
|
20 |
|
public function append($subject): void |
|
74
|
|
|
{ |
|
75
|
20 |
|
if (! $subject instanceof Process) { |
|
|
|
|
|
|
76
|
|
|
throw new \InvalidArgumentException('Wrong parameter type given, "\AOE\Crawler\Domain\Model\Process" expected!', 1593714821); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
20 |
|
parent::append($subject); |
|
80
|
20 |
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* returns array of process ids of the current collection |
|
84
|
|
|
* @return array |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getProcessIds() |
|
87
|
|
|
{ |
|
88
|
|
|
$result = []; |
|
89
|
|
|
foreach ($this->getIterator() as $value) { |
|
90
|
|
|
$result[] = $value->getProcessId(); |
|
91
|
|
|
} |
|
92
|
|
|
return $result; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|