Passed
Push — master ( 96a75e...70433e )
by Alexander
12:58
created

Parameters   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace App;
4
5
/**
6
 * Parameters provides a way to get application parameters defined in config/params.php
7
 *
8
 * In order to use in a handler or any other place supporting auto-wired injection:
9
 *
10
 * ```php
11
 * public function actionIndex(Parameters $parameters)
12
 * {
13
 *     $adminEmail = $parameters->get('admin.email', '[email protected]');
14
 * }
15
 * ```
16
 */
17
class Parameters
18
{
19
    private array $parameters;
20
21
    public function __construct(array $parameters)
22
    {
23
        $this->parameters = $parameters;
24
    }
25
26
    public function get(string $name, $default = null)
27
    {
28
        return $this->parameters[$name] ?? $default;
29
    }
30
}
31