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
Push — place-services ( fedba7 )
by Eric
03:31
created

PlaceSearchResponseIterator::next()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 21
rs 9.0534
cc 4
eloc 11
nc 4
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service\Place\Search\Response;
13
14
use Ivory\GoogleMap\Service\Place\Search\PlaceSearchService;
15
use Ivory\GoogleMap\Service\Place\Search\Request\PageTokenPlaceSearchRequest;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class PlaceSearchResponseIterator implements \Iterator
21
{
22
    /**
23
     * @var PlaceSearchService
24
     */
25
    private $service;
26
27
    /**
28
     * @var PlaceSearchResponse[]
29
     */
30
    private $responses = [];
31
32
    /**
33
     * @var int|null
34
     */
35
    private $position = 0;
36
37
    /**
38
     * @param PlaceSearchService  $service
39
     * @param PlaceSearchResponse $response
40
     */
41
    public function __construct(PlaceSearchService $service, PlaceSearchResponse $response)
42
    {
43
        $this->service = $service;
44
        $this->responses[] = $response;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function current()
51
    {
52
        if ($this->valid()) {
53
            return $this->responses[$this->position];
54
        }
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function next()
61
    {
62
        if (!$this->valid()) {
63
            return;
64
        }
65
66
        ++$this->position;
67
68
        if ($this->valid()) {
69
            return;
70
        }
71
72
        $response = end($this->responses);
73
74
        if (!$response->hasNextPageToken()) {
75
            return;
76
        }
77
78
        $request = new PageTokenPlaceSearchRequest($response);
79
        $this->responses[] = $this->service->process($request)->current();
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function key()
86
    {
87
        return $this->position;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function valid()
94
    {
95
        return $this->position < count($this->responses);
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function rewind()
102
    {
103
        $this->position = 0;
104
    }
105
}
106