Settings   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A options() 0 17 3
1
<?php namespace jlourenco\base\Models;
2
3
use Illuminate\Database\Eloquent\Model;
4
use jlourenco\support\Traits\Creation;
5
6
class Settings extends Model
7
{
8
9
    /**
10
     * To allow user actions identity (Created_by, Updated_by, Deleted_by)
11
     */
12
    use Creation;
13
14
    /**
15
     * {@inheritDoc}
16
     */
17
    protected $table = 'Settings';
18
19
    /**
20
     * {@inheritDoc}
21
     */
22
    protected $fillable = [
23
        'value'
24
    ];
25
26
    public function options()
27
    {
28
        $str = explode("* ", $this->description);
0 ignored issues
show
Documentation introduced by
The property description does not exist on object<jlourenco\base\Models\Settings>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
29
        $choices = array();
30
31
        foreach($str as $st)
32
        {
33
            preg_match('/(?P<digit>\d+) - (?P<name>\w+)/', $st, $matches);
34
            if (sizeof($matches) > 0) {
35
                $st = str_replace("*/","",$st);
36
                $st = str_replace("/*","",$st);
37
                $choices[$matches[1]] = explode($matches[1] . ' - ', $st)[1];
38
            }
39
        }
40
41
        return $choices;
42
    }
43
44
}
45