| 1 | <?php  | 
            ||
| 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 |