SpreadsheetLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A open() 0 8 1
1
<?php
2
3
namespace Akeneo\Component\SpreadsheetParser\Csv;
4
5
use Akeneo\Component\SpreadsheetParser\SpreadsheetLoaderInterface;
6
7
/**
8
 * CSV file reader
9
 *
10
 * @author    Antoine Guigan <[email protected]>
11
 * @copyright 2014 Akeneo SAS (http://www.akeneo.com)
12
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
13
 */
14
class SpreadsheetLoader implements SpreadsheetLoaderInterface
15
{
16
    /**
17
     * @var RowIteratorFactory
18
     */
19
    protected $rowIteratorFactory;
20
21
    /**
22
     * @var string
23
     */
24
    protected $spreadsheetClass;
25
26
    /**
27
     *
28
     * @var string
29
     */
30
    protected $sheetName;
31
32
    /**
33
     * Constructor
34
     *
35
     * @param RowIteratorFactory $rowIteratorFactory
36
     * @param string             $spreadsheetClass
37
     * @param string             $sheetName
38
     */
39
    public function __construct(RowIteratorFactory $rowIteratorFactory, $spreadsheetClass, $sheetName)
40
    {
41
        $this->rowIteratorFactory = $rowIteratorFactory;
42
        $this->spreadsheetClass = $spreadsheetClass;
43
        $this->sheetName = $sheetName;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function open($path, $type = null)
50
    {
51
        return new $this->spreadsheetClass(
52
            $this->rowIteratorFactory,
53
            $this->sheetName,
54
            $path
55
        );
56
    }
57
58
}
59