Spreadsheet   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getWorksheets() 0 4 1
A createRowIterator() 0 4 1
A getWorksheetIndex() 0 4 2
1
<?php
2
3
namespace Akeneo\Component\SpreadsheetParser\Csv;
4
5
use Akeneo\Component\SpreadsheetParser\SpreadsheetInterface;
6
7
/**
8
 * Represents a CSV spreadsheet
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 Spreadsheet implements SpreadsheetInterface
15
{
16
    /**
17
     * @var RowIteratorFactory
18
     */
19
    protected $rowIteratorFactory;
20
21
    /**
22
     * @var string
23
     */
24
    protected $sheetName;
25
26
    /**
27
     * @var string
28
     */
29
    protected $path;
30
31
    /**
32
     * Constructor
33
     *
34
     * @param RowIteratorFactory $rowIteratorFactory
35
     * @param string             $sheetName
36
     * @param string             $path
37
     */
38
    public function __construct(RowIteratorFactory $rowIteratorFactory, $sheetName, $path)
39
    {
40
        $this->rowIteratorFactory = $rowIteratorFactory;
41
        $this->sheetName = $sheetName;
42
        $this->path = $path;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getWorksheets()
49
    {
50
        return [$this->sheetName];
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function createRowIterator($worksheetIndex, array $options = [])
57
    {
58
        return $this->rowIteratorFactory->create($this->path, $options);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getWorksheetIndex($name)
65
    {
66
        return $this->sheetName === $name ? 0 : false;
67
    }
68
}
69