Xls   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 32
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A asArray() 0 3 2
A fetchData() 0 5 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Infrastructure Related Agent
5
 * @author Max Demian <[email protected]>
6
 */
7
8
namespace Ticaje\FileManager\Implementors\Reader\File\PhpSpreadSheet;
9
10
use Iterator;
11
use PhpOffice\PhpSpreadsheet\Reader\Xls as XlsLibrary;
12
use Ticaje\FileManager\Infrastructure\Driver\Reader\Interfaces\Gateway\XlsFileInterface;
13
14
/**
15
 * Class Xls
16
 * @package Ticaje\FileManager\Implementors\Reader\File\PhpSpreadSheet
17
 */
18
class Xls implements XlsFileInterface
19
{
20
    /** @var XlsLibrary $concretion */
21
    private $concretion;
22
23
    /**
24
     * Xls constructor.
25
     *
26
     * @param XlsLibrary $concretion
27
     */
28
    public function __construct(
29
        XlsLibrary $concretion
30
    ) {
31
        $this->concretion = $concretion;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    public function fetchData(string $fileName): Iterator
38
    {
39
        $sheet = $this->concretion->load($fileName);
40
41
        return $sheet->getActiveSheet()->getRowIterator();
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47
    public function asArray($object)
48
    {
49
        return is_array($object) ? $object : $object->toArray();
50
    }
51
}
52