Coasters   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 76
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 4 1
A next() 0 4 1
A key() 0 4 1
A valid() 0 4 1
A rewind() 0 4 1
A count() 0 4 1
A __construct() 0 5 1
1
<?php
2
3
namespace Thepixeldeveloper\Nolimits2PackageLoader;
4
5
use Countable;
6
use Iterator;
7
use SimpleXMLElement;
8
9
/**
10
 * Class Coasters
11
 * @package Thepixeldeveloper\Nolimits2PackageLoader
12
 */
13
class Coasters implements Iterator, Countable
14
{
15
    /**
16
     * @var int
17
     */
18
    protected $position = 0;
19
20
    /**
21
     * @var SimpleXMLElement
22
     */
23
    protected $parkXML;
24
25
    /**
26
     * @var Styles
27
     */
28
    protected $styles;
29
30
    /**
31
     * Coasters constructor.
32
     * @param SimpleXMLElement $parkXML
33
     * @param Styles $styles
34
     */
35
    public function __construct(SimpleXMLElement $parkXML, Styles $styles)
36
    {
37
        $this->parkXML = $parkXML;
38
        $this->styles = $styles;
39
    }
40
41
    /**
42
     * @return Coaster
43
     */
44
    public function current()
45
    {
46
        return new Coaster($this->parkXML->coaster[$this->position], $this->styles);
47
    }
48
49
    /**
50
     *
51
     */
52
    public function next()
53
    {
54
        $this->position++;
55
    }
56
57
    /**
58
     * @return int
59
     */
60
    public function key()
61
    {
62
        return $this->position;
63
    }
64
65
    /**
66
     * @return bool
67
     */
68
    public function valid()
69
    {
70
        return isset($this->parkXML->coaster[$this->position]);
71
    }
72
73
    /**
74
     *
75
     */
76
    public function rewind()
77
    {
78
        $this->position--;
79
    }
80
81
    /**
82
     * @return int
83
     */
84
    public function count()
85
    {
86
        return count($this->parkXML->coaster);
87
    }
88
}
89