Total Complexity | 4 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | trait BaseConversionTrait |
||
15 | { |
||
16 | |||
17 | use AbstractTrait; |
||
18 | |||
19 | /** |
||
20 | * Convert between arbitrary bases. |
||
21 | * |
||
22 | * `CONV($this,$from,$to)` |
||
23 | * |
||
24 | * @param int $from |
||
25 | * @param int $to |
||
26 | * @return Str |
||
27 | */ |
||
28 | public function toBase(int $from, int $to) |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Convert from an arbitrary base to base 16. |
||
35 | * |
||
36 | * `CONV($this,$from,16)` |
||
37 | * |
||
38 | * @param int $from |
||
39 | * @return Str |
||
40 | */ |
||
41 | public function toBase16(int $from = 10) |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Convert from an arbitrary base to base 2. |
||
48 | * |
||
49 | * `CONV($this,$from,2)` |
||
50 | * |
||
51 | * @param int $from |
||
52 | * @return Str |
||
53 | */ |
||
54 | public function toBase2(int $from = 10) |
||
55 | { |
||
56 | return $this->toBase($from, 2); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Convert from an arbitrary base to base 8. |
||
61 | * |
||
62 | * `CONV($this,$from,8)` |
||
63 | * |
||
64 | * @param int $from |
||
65 | * @return Str |
||
66 | */ |
||
67 | public function toBase8(int $from = 10) |
||
70 | } |
||
71 | } |
||
72 |