YmlFileReader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 32
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getFileExtension() 0 4 1
A read() 0 4 1
1
<?php
2
namespace Puppy\Config\FileReader;
3
4
use Symfony\Component\Yaml\Parser;
5
6
/**
7
 * Class YmlFileReader
8
 * @package Puppy\Config\FileReader
9
 * @author Raphaël Lefebvre <[email protected]>
10
 */
11
class YmlFileReader implements IFileReader
12
{
13
    /**
14
     * @var Parser
15
     */
16
    private $yaml;
17
18
    /**
19
     * @param Parser $yaml
0 ignored issues
show
Documentation introduced by
Should the type for parameter $yaml not be null|Parser?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
20
     */
21 2
    public function __construct(Parser $yaml = null)
22
    {
23 2
        $this->yaml = $yaml ? : new Parser();
24 2
    }
25
26
    /**
27
     * @return string
28
     */
29 1
    public function getFileExtension()
30
    {
31 1
        return '.yml';
32
    }
33
34
    /**
35
     * @param $filePath
36
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be array|string|\stdClass? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
37
     */
38 1
    public function read($filePath)
39
    {
40 1
        return $this->yaml->parse(file_get_contents($filePath), true);
41
    }
42
}
43