Completed
Push — symfony-console-application ( 3187e2...c3ee2a )
by Luis
10:39
created

plProcessorOptions::getOptions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
class plProcessorOptions 
4
{
5
    const BOOL    = 1;
6
    const STRING  = 2;
7
    const DECIMAL = 3;
8
9
    protected $properties = array();    
10
11
    public function __get( $key )
12
    {
13
        if ( !array_key_exists( $key, $this->properties ) )
14
        {
15
            throw new plProcessorOptionException( $key, plProcessorOptionException::READ );
16
        }
17
        return $this->properties[$key]['data'];
18
    }
19
20
    public function __set( $key, $val )
21
    {
22
        if ( !array_key_exists( $key, $this->properties ) )
23
        {
24
            throw new plProcessorOptionException( $key, plProcessorOptionException::WRITE );
25
        }
26
        $this->properties[$key]['data'] = $val;            
27
    }
28
29
    public function getOptions() 
30
    {
31
        $options = array();
32
        foreach( $this->properties as $key => $property ) 
33
        {
34
            $options[] = $key;
35
        }
36
        return $options;
37
    }
38
39
    public function getOptionDescription( $option ) 
40
    {
41
        if ( !array_key_exists( $option, $this->properties ) ) 
42
        {
43
            throw new plProcessorOptionException( $option, plProcessorOptionException::UNKNOWN );
44
        }
45
        return $this->properties[$option]['description'];
46
    }
47
48
    public function getOptionType( $option ) 
49
    {
50
        if ( !array_key_exists( $option, $this->properties ) ) 
51
        {
52
            throw new plProcessorOptionException( $option, plProcessorOptionException::UNKNOWN );
53
        }
54
        return $this->properties[$option]['type'];
55
    }
56
}
57
58
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
59