for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace App;
use Yiisoft\Arrays\ArrayHelper;
/**
* Parameters provides a way to get application parameters defined in config/params.php
*
* In order to use in a handler or any other place supporting auto-wired injection:
* ```php
* $params = [
* 'admin' => [
* 'email' => '[email protected]'
* ]
* ];
* ```
* public function actionIndex(Parameters $parameters)
* {
* $adminEmail = $parameters->get('admin.email', '[email protected]'); // return [email protected] or [email protected] if search key not exists in parameters
* }
*/
class Parameters
{
private array $parameters;
public function __construct(array $data)
$this->parameters = $data;
}
public function get(string $key, $default = null)
return ArrayHelper::getValue($this->parameters, $key, $default);