Completed
Push — master ( a970ae...d902d2 )
by Oscar
01:58
created

Csv   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 28
rs 10
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromString() 0 22 3
1
<?php
2
3
namespace Gettext\Extractors;
4
5
use Gettext\Translations;
6
7
/**
8
 * Class to get gettext strings from csv.
9
 */
10
class Csv extends Extractor implements ExtractorInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public static function fromString($string, Translations $translations, array $options = [])
16
    {
17
        $handle = fopen('php://memory', 'w');
18
19
        fputs($handle, $string);
20
        rewind($handle);
21
22
        $entries = [];
0 ignored issues
show
Unused Code introduced by
$entries is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
23
24
        while ($row = fgetcsv($handle)) {
25
            $translation = $translations->insert(array_shift($row), array_shift($row));
26
27
            if (!empty($row)) {
28
                $translation->setTranslation(array_shift($row));
29
                $translation->setPluralTranslations($row);
30
            }
31
        }
32
33
        fclose($handle);
34
35
        return $translations;
36
    }
37
}
38