| Total Complexity | 8 |
| Total Lines | 74 |
| Duplicated Lines | 0 % |
| Coverage | 70% |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class Token implements \JsonSerializable |
||
| 17 | { |
||
| 18 | |||
| 19 | use JsonSerializable; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var array |
||
| 23 | */ |
||
| 24 | protected $data = []; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Token constructor. |
||
| 28 | * |
||
| 29 | * @param string $data |
||
| 30 | * @param string $type |
||
| 31 | */ |
||
| 32 | 25 | public function __construct($data, $type) |
|
| 33 | { |
||
| 34 | 25 | $this->data['token'] = $data; |
|
| 35 | 25 | $this->data['type'] = $type; |
|
| 36 | 25 | $this->data['name'] = Validator::get($type); |
|
| 37 | 25 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | 4 | public function __toString() |
|
| 43 | { |
||
| 44 | 4 | return (string)$this->data['token']; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $name |
||
| 49 | * |
||
| 50 | * @return mixed |
||
| 51 | */ |
||
| 52 | 24 | public function __get($name) |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param string $name |
||
| 59 | * @param string $value |
||
| 60 | */ |
||
| 61 | 1 | public function __set($name, $value) |
|
| 62 | { |
||
| 63 | 1 | if ($name === 'type') { |
|
| 64 | $this->data['name'] = Validator::get($value); |
||
| 65 | } |
||
| 66 | |||
| 67 | 1 | if ($name === 'name') { |
|
| 68 | $this->data['type'] = Validator::get($value); |
||
| 69 | } |
||
| 70 | |||
| 71 | 1 | $this->data[$name] = $value; |
|
| 72 | 1 | } |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @param string $name |
||
| 76 | * |
||
| 77 | * @return bool |
||
| 78 | */ |
||
| 79 | public function __isset($name) |
||
| 80 | { |
||
| 81 | return isset($this->data[$name]); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return array |
||
| 86 | */ |
||
| 87 | public function __debugInfo() |
||
| 90 | } |
||
| 91 | |||
| 92 | } |
||
| 93 |