Passed
Push — master ( ae2f5d...4abed5 )
by Jhao
02:33
created

Item::isFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of RussianPost SDK package.
5
 *
6
 * © Appwilio (http://appwilio.com), greabock (https://github.com/greabock), JhaoDa (https://github.com/jhaoda)
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Appwilio\RussianPostSDK\Tracking\Packet;
15
16
class Item implements \IteratorAggregate
17
{
18
    use ErrorAware;
0 ignored issues
show
Bug introduced by
The trait Appwilio\RussianPostSDK\Tracking\Packet\ErrorAware requires the property $error which is not provided by Appwilio\RussianPostSDK\Tracking\Packet\Item.
Loading history...
19
20
    /** @var Error|null */
21
    private $Error;
0 ignored issues
show
introduced by
The private property $Error is not used, and could be removed.
Loading history...
22
23
    /** @var string */
24
    private $Barcode;
25
26
    /** @var Operation[] */
27
    private $Operation;
28
29
    /**
30
     * Список операций над постовым отправлением.
31
     *
32
     * @return Operation[]
33
     */
34
    public function getOperations()
35
    {
36
        return $this->Operation;
37
    }
38
39
    /**
40
     * Идентификатор (ШПИ) почтового отправления (Barcode).
41
     *
42
     * @return string
43
     */
44
    public function getBarcode(): string
45
    {
46
        return $this->Barcode;
47
    }
48
49
    public function isFound(): bool
50
    {
51
        return (bool) count($this->Operation);
52
    }
53
54
    public function getIterator()
55
    {
56
        return (function () {
57
            foreach ($this->getOperations() as $operation) {
58
                yield $operation;
59
            }
60
        })();
61
    }
62
}
63