Skip to content

Commit 1cbf443

Browse files
authored
Merge pull request #8 from ray-di/attribute-constructor
Take single parameter as a key in constructor
2 parents 1f34c62 + d1e2166 commit 1cbf443

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Annotation/AbstractWebContextParam.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Ray\WebContextParam\Annotation;
44

5+
use function is_array;
6+
use function is_string;
7+
58
abstract class AbstractWebContextParam
69
{
710
/**
@@ -24,13 +27,18 @@ abstract class AbstractWebContextParam
2427
public $param;
2528

2629
/**
27-
* @param array $values{key?: string, param?: string}
28-
* @param string $key
29-
* @param string $param
30+
* @param string|array{key?: string, param?: string} $values
3031
*/
31-
public function __construct(array $values = [], $key = '', $param = '')
32+
public function __construct($key)
3233
{
33-
$this->key = isset($values['key']) ? $values['key'] : $key;
34-
$this->param = isset($values['param']) ? $values['param'] : $param;
34+
if (is_array($key)) {
35+
$this->key = $key['key'];
36+
$this->param = $key['param'];
37+
38+
return;
39+
}
40+
if (is_string($key)) {
41+
$this->key = $key;
42+
}
3543
}
3644
}

0 commit comments

Comments
 (0)