1: <?php declare(strict_types = 1);
2:
3: namespace ApiGen\Info\Expr;
4:
5: use ApiGen\Info\ExprInfo;
6:
7: use function abs;
8: use function base_convert;
9:
10:
11: class IntegerExprInfo implements ExprInfo
12: {
13: public function __construct(
14: public int $value,
15: public int $base,
16: public string $raw,
17: ) {
18: }
19:
20:
21: public function toString(): string
22: {
23: if ($this->base === 10) {
24: return (string) $this->value;
25: }
26:
27: $sign = $this->value < 0 ? '-' : '';
28: $base = [2 => '0b', 8 => '0', 16 => '0x'][$this->base];
29: return $sign . $base . base_convert((string) abs($this->value), 10, $this->base);
30: }
31: }
32: