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

OptionsParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B parseOptions() 0 25 3
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
}