GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — 2.x (#7)
by
unknown
03:25
created

ResultCollection   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 1
dl 0
loc 71
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A hasResult() 0 4 1
A getText() 0 8 2
A getFormat() 0 8 2
A __toString() 0 8 2
A getResults() 0 4 1
A addResult() 0 4 1
A isEmpty() 0 4 1
A getIterator() 0 4 1
A count() 0 4 1
1
<?php
2
3
namespace RobbieP\ZbarQrdecoder\Result;
4
5
class ResultCollection extends AbstractResult implements \IteratorAggregate, \Countable
6
{
7
    public function hasResult()
8
    {
9
        return !$this->isEmpty();
10
    }
11
12
    public function getText()
13
    {
14
        if ($this->isEmpty()) {
15
            throw new \LogicException('Empty result set.');
16
        }
17
18
        return $this->results[0]->getText();
19
    }
20
21
    public function getFormat()
22
    {
23
        if ($this->isEmpty()) {
24
            throw new \LogicException('Empty result set.');
25
        }
26
27
        return $this->results[0]->getFormat();
28
    }
29
30
    public function __toString()
31
    {
32
        if ($this->isEmpty()) {
33
            return 'No result';
34
        }
35
36
        return (string)$this->results[0];
37
    }
38
39
40
    /**
41
     * @var AbstractResult[]
42
     */
43
    public $results = [];
44
45
    /**
46
     * @return AbstractResult[]
47
     */
48
    public function getResults()
49
    {
50
        return $this->results;
51
    }
52
53
    public function addResult(AbstractResult $result)
54
    {
55
        $this->results[] = $result;
56
    }
57
58
    /**
59
     * @return bool
60
     */
61
    public function isEmpty()
62
    {
63
        return count($this->results) === 0;
64
    }
65
66
    public function getIterator()
67
    {
68
        return new \ArrayIterator($this->results);
69
    }
70
71
    public function count()
72
    {
73
        return count($this->results);
74
    }
75
}
76