| Total Complexity | 9 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | class PhpTokenBase |
||
| 26 | { |
||
| 27 | /** @var int */ |
||
| 28 | protected $identifier = 0; |
||
| 29 | /** @var string */ |
||
| 30 | protected $name = 'UNKNOWN'; |
||
| 31 | /** @var int */ |
||
| 32 | protected $line = 0; |
||
| 33 | /** @var string */ |
||
| 34 | protected $content = ''; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Token constructor |
||
| 38 | * |
||
| 39 | * @param string|array $token |
||
| 40 | * @param ValidatorInterface $validator |
||
| 41 | * |
||
| 42 | * @throws \Exception |
||
| 43 | */ |
||
| 44 | 6 | public function __construct($token, ValidatorInterface $validator) |
|
| 45 | { |
||
| 46 | 6 | if (!$validator->check($token)) { |
|
| 47 | 1 | throw new \Exception('Not valid token value'); |
|
| 48 | } |
||
| 49 | |||
| 50 | 5 | if (is_string($token)) { |
|
| 51 | 4 | $this->content = $token; |
|
| 52 | |||
| 53 | 4 | return; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | $this->identifier = $token[0]; |
|
| 57 | 1 | $this->content = $token[1]; |
|
| 58 | 1 | $this->line = $token[2]; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param string $content |
||
| 63 | */ |
||
| 64 | 1 | public function setContent($content) |
|
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | 2 | public function getContent() |
|
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @param int $identifier |
||
| 79 | */ |
||
| 80 | 2 | public function setId($identifier) |
|
| 81 | { |
||
| 82 | 2 | $this->identifier = $identifier; |
|
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @return int |
||
| 87 | */ |
||
| 88 | 3 | public function getId() |
|
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @param int $line |
||
| 95 | */ |
||
| 96 | 1 | public function setLine($line) |
|
| 97 | { |
||
| 98 | 1 | $this->line = $line; |
|
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @return int |
||
| 103 | */ |
||
| 104 | 2 | public function getLine() |
|
| 107 | } |
||
| 108 | } |
||
| 109 |