WebpageDTOArray::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * File: WebpageDTOArray.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\Otomoto\Middleware\Webpage\Data;
10
11
use Iterator;
12
use IteratorIterator;
13
use ArrayIterator;
14
15
/**
16
 * Class WebpageDTOArray
17
 * @package MSlwk\Otomoto\Middleware\Webpage\Data
18
 */
19
class WebpageDTOArray extends IteratorIterator implements Iterator
20
{
21
    /**
22
     * UrlDTOArray constructor.
23
     * @param WebpageDTOInterface[]|null[] ...$webpageDTOs
24
     */
25 22
    public function __construct(?WebpageDTOInterface ...$webpageDTOs)
26
    {
27 22
        parent::__construct(new ArrayIterator($webpageDTOs));
28 22
    }
29
30
    /**
31
     * @return WebpageDTOInterface
32
     */
33 6
    public function current(): WebpageDTOInterface
34
    {
35 6
        return $this->getInnerIterator()->current();
36
    }
37
38
    /**
39
     * @param WebpageDTOInterface $webpageDTO
40
     */
41 6
    public function add(WebpageDTOInterface $webpageDTO): void
42
    {
43 6
        $this->getInnerIterator()->append($webpageDTO);
0 ignored issues
show
Bug introduced by
The method append() does not exist on Iterator. It seems like you code against a sub-type of Iterator such as AppendIterator or ArrayIterator or RecursiveArrayIterator. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $this->getInnerIterator()->/** @scrutinizer ignore-call */ append($webpageDTO);
Loading history...
44 6
    }
45
46
    /**
47
     * @param int $key
48
     * @param WebpageDTOInterface $webpageDTO
49
     */
50 3
    public function set(int $key, WebpageDTOInterface $webpageDTO): void
51
    {
52 3
        $this->getInnerIterator()->offsetSet($key, $webpageDTO);
0 ignored issues
show
Bug introduced by
The method offsetSet() does not exist on Iterator. It seems like you code against a sub-type of Iterator such as SplDoublyLinkedList or Yaf_Config_Simple or SplFixedArray or SplObjectStorage or Yaf\Session or TheSeer\Tokenizer\TokenCollection or Yaf_Session or Yaf\Config\Simple or Yaf\Config\Ini or SolrDocument or Yaf_Config_Ini or CachingIterator or PHP_Token_Stream or Phar or ArrayIterator or Phar or Phar or RecursiveCachingIterator or RecursiveArrayIterator or SimpleXMLIterator or Phar. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
        $this->getInnerIterator()->/** @scrutinizer ignore-call */ offsetSet($key, $webpageDTO);
Loading history...
53 3
    }
54
55
    /**
56
     * @param int $key
57
     * @return WebpageDTOInterface
58
     */
59 11
    public function get(int $key): WebpageDTOInterface
60
    {
61 11
        return $this->getInnerIterator()->offsetGet($key);
0 ignored issues
show
Bug introduced by
The method offsetGet() does not exist on Iterator. It seems like you code against a sub-type of Iterator such as SplDoublyLinkedList or Yaf_Config_Simple or SplFixedArray or SplObjectStorage or Yaf\Session or TheSeer\Tokenizer\TokenCollection or Yaf_Session or Yaf\Config\Simple or Yaf\Config\Ini or SolrDocument or Yaf_Config_Ini or CachingIterator or PHP_Token_Stream or Phar or ArrayIterator or Phar or Phar or RecursiveCachingIterator or RecursiveArrayIterator or SimpleXMLIterator or Phar. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
        return $this->getInnerIterator()->/** @scrutinizer ignore-call */ offsetGet($key);
Loading history...
62
    }
63
64
    /**
65
     * @return int
66
     */
67 7
    public function count(): int
68
    {
69 7
        return $this->getInnerIterator()->count();
0 ignored issues
show
Bug introduced by
The method count() does not exist on Iterator. It seems like you code against a sub-type of Iterator such as JsonSchema\Iterator\ObjectIterator or SplDoublyLinkedList or HttpMessage or HttpRequestPool or Yaf_Config_Simple or SplFixedArray or SplObjectStorage or Yaf\Session or SQLiteResult or MSlwk\Otomoto\App\Manufa...ta\ManufacturerDTOArray or Imagick or TheSeer\Tokenizer\TokenCollection or MSlwk\Otomoto\Middleware\Webpage\Data\UrlDTOArray or Yaf_Session or SplPriorityQueue or MSlwk\Otomoto\Middleware...ge\Data\WebpageDTOArray or Yaf\Config\Simple or MSlwk\Otomoto\App\Model\Data\ModelDTOArray or Yaf\Config\Ini or MSlwk\Otomoto\App\Stats\Filter\FilterArray or MongoCursor or Yaf_Config_Ini or SplHeap or MongoGridFSCursor or MSlwk\Otomoto\App\Manufa...ta\ManufacturerDTOArray or MSlwk\Otomoto\Middleware\Webpage\Data\UrlDTOArray or MSlwk\Otomoto\Middleware...ge\Data\WebpageDTOArray or CachingIterator or MSlwk\Otomoto\App\Model\Data\ModelDTOArray or MSlwk\Otomoto\App\Stats\Filter\FilterArray or PHP_Token_Stream or Phar or ArrayIterator or GlobIterator or Phar or Phar or RecursiveCachingIterator or RecursiveArrayIterator or SimpleXMLIterator or Phar. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

69
        return $this->getInnerIterator()->/** @scrutinizer ignore-call */ count();
Loading history...
70
    }
71
}
72