Cell   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 77
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCellValue() 0 10 1
A getCellValueByColumnAndRow() 0 10 1
A getCellsValues() 0 11 2
1
<?php
2
3
namespace EFParser;
4
5
use EFParserInterface\ICellParser,
6
    EFParserInterface\IExcel;
7
/**
8
 * Class Cell
9
 * Класс для парсинга ячеек
10
 */
11
class Cell implements ICellParser
12
{
13
    private $parser;
14
15
    /**
16
     * Конструктор
17
     *
18
     * @param IExcel $excel (Класс реализующий IExcel интерфейс)
19
     */
20 3
    public function __construct(IExcel $excel)
21
    {
22 3
        $this->parser = $excel;
23 3
    }
24
25
    /**
26
     * Метод для чтения значения ячейки по адресу (A1 etc)
27
     *
28
     * @param string  $cell         (Адрес ячейки)
29
     * @param string  $sheetName    (Название листа, которому пренадлежит эта ячейка)
30
     *
31
     * @return mixed $value        (Значение)
32
     */
33 2
    public function getCellValue($cell, $sheetName)
34
    {
35 2
        $value = $this->parser->sourceReader
0 ignored issues
show
Bug introduced by
Accessing sourceReader on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
36 2
                              ->load($this->parser->sourceFilePath.$this->parser->sourceFile)
0 ignored issues
show
Bug introduced by
Accessing sourceFilePath on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
Bug introduced by
Accessing sourceFile on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
37 2
                              ->setActiveSheetIndexByName($sheetName)
38 2
                              ->getCell($cell)
39 2
                              ->getValue();
40
41 2
        return $value;
42
    }
43
44
    /**
45
     * Метод для чтения значения ячейки (по координатам)
46
     *
47
     * @param string $column    (Буквенный индекс колонки)
48
     * @param int    $row       (Индекс строки)
49
     * @param string $sheetName (Название листа, которому пренадлежит эта ячейка)
50
     *
51
     * @return mixed $value     (Значение)
52
     */
53 1
    public function getCellValueByColumnAndRow($column, $row, $sheetName)
54
    {
55 1
        $value = $this->parser->sourceReader
0 ignored issues
show
Bug introduced by
Accessing sourceReader on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
56 1
                              ->load($this->parser->sourceFilePath.$this->parser->sourceFile)
0 ignored issues
show
Bug introduced by
Accessing sourceFilePath on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
Bug introduced by
Accessing sourceFile on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
57 1
                              ->setActiveSheetIndexByName($sheetName)
58 1
                              ->getCellByColumnAndRow($column, $row)
59 1
                              ->getValue();
60
61 1
        return $value;
62
    }
63
64
    /**
65
     * Метод для чтения значениий нескольких ячеек
66
     *
67
     * @param array  $cells     (Массив ячеек)
68
     *
69
     * ```php
70
     * $cells = array("A27", "C28", "I27", "E49");
71
     * ```
72
     * @param string $sheetName (Название листа, которому пренадлежат эти ячейки)
73
     *
74
     * @return array $value     (Массив значений)
75
     */
76 1
    public function getCellsValues(array $cells, $sheetName)
77
    {
78 1
        $value = array();
79
80 1
        foreach ($cells as $cell)
81
        {
82 1
            $value[$cell] = $this->getCellValue($cell, $sheetName);
83 1
        }
84
85 1
        return $value;
86
    }
87
}