Completed
Push — master ( afdf8f...03c0bd )
by
unknown
05:18
created

ArrayAbstractExport   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 7
eloc 15
c 2
b 1
f 0
dl 0
loc 45
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A key() 0 3 1
A current() 0 3 1
A rewind() 0 18 3
A next() 0 3 1
A valid() 0 3 1
1
<?php
2
/*************************************************************************************/
3
/*      This file is part of the Thelia package.                                     */
4
/*                                                                                   */
5
/*      Copyright (c) OpenStudio                                                     */
6
/*      email : [email protected]                                                       */
7
/*      web : http://www.thelia.net                                                  */
8
/*                                                                                   */
9
/*      For the full copyright and license information, please view the LICENSE.txt  */
10
/*      file that was distributed with this source code.                             */
11
/*************************************************************************************/
12
13
namespace Thelia\ImportExport\Export;
14
15
abstract class ArrayAbstractExport extends AbstractExport
0 ignored issues
show
Deprecated Code introduced by
The class Thelia\ImportExport\Export\AbstractExport has been deprecated: since 2.4, please use a specific AbstractExport (like JsonFileAbstractExport). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

15
abstract class ArrayAbstractExport extends /** @scrutinizer ignore-deprecated */ AbstractExport
Loading history...
16
{
17
    /**
18
     * @var array Data to export
19
     */
20
    private $data;
21
22
    public function current()
23
    {
24
        return current($this->data);
25
    }
26
27
    public function key()
28
    {
29
        return key($this->data);
30
    }
31
32
    public function next()
33
    {
34
        next($this->data);
35
    }
36
37
    public function rewind()
38
    {
39
        if ($this->data === null) {
40
            $data = $this->getData();
41
42
            if (\is_array($data)) {
43
                $this->data = $data;
44
                reset($this->data);
45
46
                return;
47
            }
48
49
            throw new \DomainException(
50
                'Data must be an array.'
51
            );
52
        }
53
54
        throw new \LogicException('Export data can\'t be rewinded');
55
    }
56
57
    public function valid()
58
    {
59
        return key($this->data) !== null;
60
    }
61
}
62