Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 54 |
|
0.00% |
0 / 11 |
CRAP | |
0.00% |
0 / 1 |
| Location | |
0.00% |
0 / 54 |
|
0.00% |
0 / 11 |
462 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| create | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| readByName | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |||
| readById | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |||
| update | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| delete | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getOnSite | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setOnSite | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
56 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BuyerKiosk\Backstock; |
| 4 | |
| 5 | class Location extends Backstock |
| 6 | { |
| 7 | |
| 8 | public $id; |
| 9 | public $name; |
| 10 | public $onsite; |
| 11 | |
| 12 | public function __construct(\Store $store) |
| 13 | { |
| 14 | parent::__construct($store); |
| 15 | } |
| 16 | |
| 17 | public function create() |
| 18 | { |
| 19 | $stmt = $this->storeDB->prepare("INSERT INTO bsLocations (name, onsite) VALUES (:name, :onsite)"); |
| 20 | $stmt->bindValue(":name", $this->name); |
| 21 | $stmt->bindValue(":onsite", $this->onsite); |
| 22 | $stmt->execute(); |
| 23 | $this->id = $this->storeDB->lastInsertId(); |
| 24 | return $this; |
| 25 | } |
| 26 | |
| 27 | public function readByName($name) |
| 28 | { |
| 29 | $stmt = $this->storeDB->prepare("SELECT id, onsite FROM bsLocations WHERE name=:name"); |
| 30 | $stmt->bindValue(":name", $name); |
| 31 | if ($stmt->execute()) { |
| 32 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 33 | if ($row) { |
| 34 | $this->id = $row['id']; |
| 35 | $this->onsite = $row['onsite']; |
| 36 | $this->name = $name; |
| 37 | return $this; |
| 38 | } |
| 39 | } |
| 40 | return null; |
| 41 | } |
| 42 | |
| 43 | public function readById($id) |
| 44 | { |
| 45 | $stmt = $this->storeDB->prepare("SELECT name, onsite FROM bsLocations WHERE id=:id"); |
| 46 | $stmt->bindValue(":id", $id); |
| 47 | if ($stmt->execute()) { |
| 48 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 49 | if ($row) { |
| 50 | $this->id = $id; |
| 51 | $this->name = $row['name']; |
| 52 | $this->onsite = $row['onsite']; |
| 53 | } |
| 54 | } |
| 55 | return $this; |
| 56 | } |
| 57 | |
| 58 | public function update() |
| 59 | { |
| 60 | $stmt = $this->storeDB->prepare("UPDATE bsLocations SET name=:name, onsite=:onsite WHERE id = :id"); |
| 61 | $stmt->bindValue(":name", $this->name); |
| 62 | $stmt->bindValue(":onsite", $this->onsite); |
| 63 | $stmt->bindValue(":id", $this->id); |
| 64 | $stmt->execute(); |
| 65 | return $this; |
| 66 | } |
| 67 | |
| 68 | public function delete() |
| 69 | { |
| 70 | $stmt = $this->storeDB->prepare("DELETE FROM bsLocations WHERE id = :id"); |
| 71 | $stmt->bindValue(":id", $this->id); |
| 72 | $stmt->execute(); |
| 73 | return $this; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @return mixed |
| 78 | */ |
| 79 | public function getId() |
| 80 | { |
| 81 | return $this->id; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @return mixed |
| 86 | */ |
| 87 | public function getName() |
| 88 | { |
| 89 | return $this->name; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @param mixed $name |
| 94 | */ |
| 95 | public function setName($name) |
| 96 | { |
| 97 | $this->name = $name; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return mixed |
| 102 | */ |
| 103 | public function getOnSite() |
| 104 | { |
| 105 | return $this->onsite; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @param mixed $onsite |
| 110 | */ |
| 111 | public function setOnSite($onsite) |
| 112 | { |
| 113 | error_log($onsite); |
| 114 | if (is_bool($onsite)) { |
| 115 | if ($onsite) { |
| 116 | $this->onsite = 1; |
| 117 | } else { |
| 118 | $this->onsite = 0; |
| 119 | } |
| 120 | } else { |
| 121 | if (is_int($onsite)) { |
| 122 | if ($onsite > 0) { |
| 123 | $this->onsite = 1; |
| 124 | } else { |
| 125 | $this->onsite = 0; |
| 126 | } |
| 127 | } else { |
| 128 | if (is_string($onsite)) { |
| 129 | if ($onsite == "true") { |
| 130 | $this->onsite = 1; |
| 131 | } else { |
| 132 | $this->onsite = 0; |
| 133 | } |
| 134 | } else { |
| 135 | $this->onsite = 1; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | |
| 142 | } |