1 | <?php |
||
16 | class Repository |
||
17 | { |
||
18 | /** |
||
19 | * The eloquent model instance. |
||
20 | * |
||
21 | * @var \Gitamin\Models\Setting |
||
22 | */ |
||
23 | protected $model; |
||
24 | |||
25 | /** |
||
26 | * Cache of the settings. |
||
27 | * |
||
28 | * @var array|null |
||
29 | */ |
||
30 | protected $settings; |
||
31 | |||
32 | /** |
||
33 | * Create a new settings service instance. |
||
34 | * |
||
35 | * @param \Gitamin\Models\Setting $model |
||
36 | */ |
||
37 | public function __construct(Setting $model) |
||
41 | |||
42 | /** |
||
43 | * Returns a setting from the database. |
||
44 | * |
||
45 | * @param string $name |
||
46 | * @param string|null $default |
||
47 | * |
||
48 | * @return string|null |
||
49 | */ |
||
50 | public function get($name, $default = null) |
||
51 | { |
||
52 | // if we've not loaded the settings, load them now |
||
53 | if (! $this->settings) { |
||
54 | $this->settings = $this->model->all()->lists('value', 'name'); |
||
|
|||
55 | } |
||
56 | |||
57 | // if the setting exists and is not blank, return it |
||
58 | if (! empty($this->settings[$name])) { |
||
59 | return $this->settings[$name]; |
||
60 | } |
||
61 | |||
62 | return $default; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Creates or updates a setting value. |
||
67 | * |
||
68 | * @param string $name |
||
69 | * @param string $value |
||
70 | */ |
||
71 | public function set($name, $value) |
||
81 | } |
||
82 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..