ObjectIterator::rewind()   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 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * soluble-japha / PHPJavaBridge driver client.
6
 *
7
 * Refactored version of phpjababridge's Java.inc file compatible
8
 * with php java bridge 6.2
9
 *
10
 *
11
 * @credits   http://php-java-bridge.sourceforge.net/pjb/
12
 *
13
 * @see      http://github.com/belgattitude/soluble-japha
14
 *
15
 * @author Jost Boekemeier
16
 * @author Vanvelthem Sébastien (refactoring and fixes from original implementation)
17
 * @license   MIT
18
 *
19
 * The MIT License (MIT)
20
 * Copyright (c) 2014-2017 Jost Boekemeier
21
 * Permission is hereby granted, free of charge, to any person obtaining a copy
22
 * of this software and associated documentation files (the "Software"), to deal
23
 * in the Software without restriction, including without limitation the rights
24
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
 * copies of the Software, and to permit persons to whom the Software is
26
 * furnished to do so, subject to the following conditions:
27
 *
28
 * The above copyright notice and this permission notice shall be included in
29
 * all copies or substantial portions of the Software.
30
 *
31
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
37
 * THE SOFTWARE.
38
 */
39
40
namespace Soluble\Japha\Bridge\Driver\Pjb62;
41
42
use Iterator;
43
use Soluble\Japha\Interfaces\JavaObject;
44
45
class ObjectIterator implements Iterator
46
{
47
    /**
48
     * @var array
49
     */
50
    private $var;
51
52
    /**
53
     * @param JavaObject|JavaType $javaObject
54
     */
55 8
    public function __construct($javaObject)
56
    {
57 8
        $this->var = Pjb62Driver::castPjbInternal($javaObject, 'A');
58 8
    }
59
60 8
    public function rewind(): void
61
    {
62 8
        reset($this->var);
63 8
    }
64
65
    /**
66
     * @return bool
67
     */
68 8
    public function valid(): bool
69
    {
70 8
        return $this->current() !== false;
71
    }
72
73
    /**
74
     * @return mixed
75
     */
76 8
    public function next()
77
    {
78 8
        return next($this->var);
79
    }
80
81
    /**
82
     * @return int|string
83
     */
84 5
    public function key()
85
    {
86 5
        return key($this->var);
87
    }
88
89
    /**
90
     * @return mixed
91
     */
92 8
    public function current()
93
    {
94 8
        return current($this->var);
95
    }
96
}
97