Skip to content

Commit

Permalink
Merge pull request #8 from ray-di/attribute-constructor
Browse files Browse the repository at this point in the history
Take single parameter as a key in constructor
  • Loading branch information
koriym authored Jan 10, 2021
2 parents 1f34c62 + d1e2166 commit 1cbf443
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Annotation/AbstractWebContextParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Ray\WebContextParam\Annotation;

use function is_array;
use function is_string;

abstract class AbstractWebContextParam
{
/**
Expand All @@ -24,13 +27,18 @@ abstract class AbstractWebContextParam
public $param;

/**
* @param array $values{key?: string, param?: string}
* @param string $key
* @param string $param
* @param string|array{key?: string, param?: string} $values
*/
public function __construct(array $values = [], $key = '', $param = '')
public function __construct($key)
{
$this->key = isset($values['key']) ? $values['key'] : $key;
$this->param = isset($values['param']) ? $values['param'] : $param;
if (is_array($key)) {
$this->key = $key['key'];
$this->param = $key['param'];

return;
}
if (is_string($key)) {
$this->key = $key;
}
}
}

0 comments on commit 1cbf443

Please sign in to comment.