| Total Complexity | 5 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | class TrackingCode implements \JsonSerializable { |
||
| 22 | /** |
||
| 23 | * Code. |
||
| 24 | * |
||
| 25 | * Your Unique Transaction Reference. Minimum length: 8 characters. |
||
| 26 | * |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | private $code; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Construct and initialize tracking code. |
||
| 33 | * |
||
| 34 | * @param string $code Code. |
||
| 35 | * @return void |
||
| 36 | * @throws \InvalidArgumentException Throws exception if length of code is less than 8 characters. |
||
| 37 | */ |
||
| 38 | 3 | public function __construct( $code ) { |
|
| 44 | 2 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * From ID. |
||
| 48 | * |
||
| 49 | * @param string|int $id ID. |
||
| 50 | * @return self |
||
| 51 | */ |
||
| 52 | 2 | public static function from_id( $id ) { |
|
| 53 | 2 | return new self( \sprintf( '%08s', $id ) ); |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * JSON serialize. |
||
| 58 | * |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | 2 | public function jsonSerialize() { |
|
| 62 | 2 | return $this->code; |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * To string. |
||
| 67 | * |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | 2 | public function __toString() { |
|
| 72 | } |
||
| 73 | } |
||
| 74 |