Passed
Branch ignore-files (1e3f4a)
by Natan
02:30
created

OptionsParser::parseOptions()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 25
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
namespace SnifferReport\Service;
3
4
use SnifferReport\Exception\UnableToParseOptionsException;
5
6
class OptionsParser
7
{
8
    /**
9
     * Parses the options sent by the user.
10
     *
11
     * @param string $options
12
     *
13
     * @return array|null $parsed_options
14
     *
15
     * @throws UnableToParseOptionsException
16
     */
17
    public static function parseOptions($options)
18
    {
19
        if (empty($options)) {
20
            return null;
21
        }
22
23
        $decoded_options = json_decode($options);
24
        if (empty($decoded_options)) {
25
            throw new UnableToParseOptionsException();
26
        }
27
28
        // @fixme: process $decoded_options->included_extensions
29
        // regex: ^.*((\.inc)|(\.php))$
30
31
        // @fixme: process $decoded_options->excluded_extensions
32
        // regex: ^.*(?<!(\.inc)|(\.php))$
33
34
        // @fixme: process $decoded_options->excluded_files
35
        // regex: ^(FilesHandler.php)|(GitHandler.inc)$
36
37
        // @fixme: process $decoded_options->included_files
38
        // regex: ?
39
40
        return $parsed_options;
0 ignored issues
show
Bug introduced by
The variable $parsed_options does not exist. Did you mean $options?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
41
    }
42
}