|
1 | 1 | <?php
|
2 |
| - |
3 | 2 | namespace BNETDocs\Libraries;
|
4 | 3 |
|
| 4 | +use \BNETDocs\Libraries\Exceptions\ProductNotFoundException; |
| 5 | +use \BNETDocs\Libraries\Exceptions\QueryException; |
5 | 6 | use \CarlBennett\MVC\Libraries\Common;
|
6 | 7 | use \CarlBennett\MVC\Libraries\Database;
|
7 | 8 | use \CarlBennett\MVC\Libraries\DatabaseDriver;
|
8 |
| -use \BNETDocs\Libraries\Exceptions\ProductNotFoundException; |
9 |
| -use \BNETDocs\Libraries\Exceptions\QueryException; |
10 | 9 | use \InvalidArgumentException;
|
| 10 | +use \JsonSerializable; |
11 | 11 | use \PDO;
|
12 | 12 | use \PDOException;
|
13 | 13 | use \StdClass;
|
14 | 14 |
|
15 |
| -class Product { |
| 15 | +class Product implements JsonSerializable { |
16 | 16 |
|
17 | 17 | protected $bnet_product_id;
|
18 | 18 | protected $bnet_product_raw;
|
@@ -108,6 +108,18 @@ public function getVersionByte() {
|
108 | 108 | return $this->version_byte;
|
109 | 109 | }
|
110 | 110 |
|
| 111 | + public function jsonSerialize() |
| 112 | + { |
| 113 | + return [ |
| 114 | + 'bnet_product_id' => $this->getBnetProductId(), |
| 115 | + 'bnet_product_raw' => $this->getBnetProductRaw(), |
| 116 | + 'bnls_product_id' => $this->getBnlsProductId(), |
| 117 | + 'label' => $this->getLabel(), |
| 118 | + 'sort' => $this->getSort(), |
| 119 | + 'version_byte' => $this->getVersionByte(), |
| 120 | + ]; |
| 121 | + } |
| 122 | + |
111 | 123 | protected static function normalize(StdClass &$data) {
|
112 | 124 | $data->bnet_product_id = (int) $data->bnet_product_id;
|
113 | 125 | $data->bnet_product_raw = (string) $data->bnet_product_raw;
|
|
0 commit comments