Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 59 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| Product | |
0.00% |
0 / 59 |
|
0.00% |
0 / 6 |
272 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| mapJSON | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 | |||
| mapFromEncodedJSON | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| mapFromRow | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
20 | |||
| mapFromObj | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 | |||
| verify | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
72 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BuyerKiosk\Shopify; |
| 4 | |
| 5 | class Product { |
| 6 | private $id; |
| 7 | public $productID; |
| 8 | public $sku; |
| 9 | public $title; |
| 10 | public $sent; |
| 11 | public $description; |
| 12 | public $brand; |
| 13 | public $type; |
| 14 | public $tags; |
| 15 | public $color; |
| 16 | public $size; |
| 17 | public $price; |
| 18 | public $quantity; |
| 19 | public $images; |
| 20 | public $added; |
| 21 | |
| 22 | public function __construct() |
| 23 | { |
| 24 | |
| 25 | } |
| 26 | public function mapJSON($json) { |
| 27 | $data = json_decode($json); |
| 28 | $this->productID = $data->productID; |
| 29 | $this->sku = $data->sku; |
| 30 | $this->title = $data->title; |
| 31 | $this->description = $data->description; |
| 32 | $this->brand = $data->brand; |
| 33 | $this->type = $data->type; |
| 34 | $this->tags = $data->tags; |
| 35 | $this->color = $data->color; |
| 36 | $this->size = $data->size; |
| 37 | $this->price = $data->price; |
| 38 | $this->quantity = $data->quantity; |
| 39 | $this->images = $data->images; |
| 40 | } |
| 41 | public function mapFromEncodedJSON($json) { |
| 42 | $data = json_decode($json); |
| 43 | $this->sku = $data->SKU; |
| 44 | $this->title = $data->Title; |
| 45 | $this->description = $data->Description; |
| 46 | $this->brand = $data->Brand; |
| 47 | $this->type = $data->Type; |
| 48 | $this->tags = $data->Tags; |
| 49 | $this->color = $data->Color; |
| 50 | $this->size = $data->Size; |
| 51 | $this->price = $data->Price; |
| 52 | $this->quantity = $data->Quantity; |
| 53 | $this->images = $data->Images; |
| 54 | } |
| 55 | public function mapFromRow($row) { |
| 56 | if(isset($row['productID'])) { |
| 57 | $this->productID = $row['productID']; |
| 58 | } |
| 59 | if(isset($row['added'])) { |
| 60 | $this->added = $row['added']; |
| 61 | } |
| 62 | if(isset($row['sent'])) { |
| 63 | $this->sent = $row['sent']; |
| 64 | } |
| 65 | $this->sku = $row['sku']; |
| 66 | $this->title = $row['title']; |
| 67 | $this->description = $row['description']; |
| 68 | $this->brand = $row['brand']; |
| 69 | $this->type = $row['type']; |
| 70 | $this->tags = $row['tags']; |
| 71 | $this->color = $row['color']; |
| 72 | $this->size = $row['size']; |
| 73 | $this->price = $row['price']; |
| 74 | $this->quantity = $row['quantity']; |
| 75 | $this->images = $row['images']; |
| 76 | $this->id = $row['id']; |
| 77 | |
| 78 | } |
| 79 | public function mapFromObj($obj) { |
| 80 | $this->productID = $obj->productID; |
| 81 | $this->sku = $obj->sku; |
| 82 | $this->title = $obj->title; |
| 83 | $this->description = $obj->description; |
| 84 | $this->brand = $obj->brand; |
| 85 | $this->type = $obj->type; |
| 86 | $this->tags = $obj->tags; |
| 87 | $this->color = $obj->color; |
| 88 | $this->size = $obj->size; |
| 89 | $this->price = $obj->price; |
| 90 | $this->quantity = $obj->quantity; |
| 91 | $this->images = $obj->images; |
| 92 | $this->sent = $obj->sent; |
| 93 | $this->added = $obj->added; |
| 94 | } |
| 95 | |
| 96 | public function verify() { |
| 97 | return isset($this->sku) && isset($this->title) && isset($this->brand) && isset($this->type) && isset($this->tags) && isset($this->color) && isset($this->size) && isset($this->price); |
| 98 | } |
| 99 | } |