AbstractXMLDictionnary   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
readNext() 0 1 ?
A get() 0 11 4
1
<?php
2
3
namespace Akeneo\Component\SpreadsheetParser\Xlsx;
4
5
/**
6
 * Base class for XML dictionnary resources
7
 *
8
 * @author    Antoine Guigan <[email protected]>
9
 * @copyright 2014 Akeneo SAS (http://www.akeneo.com)
10
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
11
 */
12
abstract class AbstractXMLDictionnary extends AbstractXMLResource
13
{
14
    /**
15
     * @var boolean
16
     */
17
    protected $valid = true;
18
19
    /**
20
     * @var array
21
     */
22
    protected $values = [];
23
24
    /**
25
     * Returns a shared string by index
26
     *
27
     * @param int $index
28
     *
29
     * @throws \InvalidArgumentException
30
     */
31
    public function get($index)
32
    {
33
        while ($this->valid && !isset($this->values[$index])) {
34
            $this->readNext();
35
        }
36
        if ((!isset($this->values[$index]))) {
37
            throw new \InvalidArgumentException(sprintf('No value with index %s', $index));
38
        }
39
40
        return $this->values[$index];
41
    }
42
43
    /**
44
     * Reads the next value in the file
45
     */
46
    abstract protected function readNext();
47
}
48