CsvUnserialiser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 30
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A unserialise() 0 21 2
1
<?php
2
3
/*
4
 * This file is part of Payload.
5
 *
6
 * (c) DraperStudio <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DraperStudio\Payload\Unserialisers;
13
14
use DraperStudio\Payload\Contracts\Unserialiser;
15
use DraperStudio\Payload\Utils\Mapper;
16
use League\Csv\Reader;
17
18
/**
19
 * Class CsvUnserialiser.
20
 */
21
class CsvUnserialiser implements Unserialiser
22
{
23
    /**
24
     * @param $input
25
     * @param null $class
26
     *
27
     * @return mixed
28
     */
29 6
    public function unserialise($input, $class = null)
30
    {
31 6
        $reader = Reader::createFromString($input);
32
33 6
        $contents = $reader->fetchAll();
34
35
        // @deprecated for the moment
36
        // for ($i = 0; $i < count($contents); ++$i) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
        //     if ($i <= 0) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
        //         continue;
39
        //     }
40
        //
41
        //     $contents[$i] = array_combine($contents[0], $contents[$i]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
        // }
43
44 6
        if (!is_null($class)) {
45
            return (new Mapper())->map($contents, $class);
46
        }
47
48 6
        return $contents;
49
    }
50
}
51