Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 34 |
| App\Controllers\CartControlController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 34 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| add | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 11 |
|||
| delete | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
| update | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 11 |
|||
| <?php | |
| namespace App\Controllers; | |
| use App\Models\ArticleDatabase; | |
| class CartControlController extends \Core\Controller { | |
| private $cart; | |
| private $quantity; | |
| private $id; | |
| private $articledatabase; | |
| public function __construct($route_params) { | |
| parent::__construct($route_params); | |
| $this->cart = \App\Models\Cart::getInstance(); | |
| $this->articledatabase = new ArticleDatabase(); | |
| } | |
| public function add() { | |
| $post = $this->request->getPost(); | |
| if (filter_var($post['quantity'], FILTER_VALIDATE_INT, ["options" => ["min_range"=>1, "max_range"=>99]]) == true) { | |
| $this->id = $post['id']; | |
| $this->quantity = $post['quantity']; | |
| $article = $this->articledatabase->findByID($this->id); | |
| $this->cart->addArticle($article, $this->quantity); | |
| header('Location: /cart'); | |
| } else { | |
| echo "Bitte gib eine valide Anzahl (1-99) der zu kaufenden Produkte an."; | |
| } | |
| } | |
| public function delete() { | |
| $post = $this->request->getPost(); | |
| if ($post) { | |
| $this->id = $post['id']; | |
| $article = $this->articledatabase->findByID($this->id); | |
| $this->cart->deleteArticle($article); | |
| header('Location: /cart'); | |
| } | |
| } | |
| public function update() { | |
| $post = $this->request->getPost(); | |
| if (filter_var($post['quantity'], FILTER_VALIDATE_INT, ["options" => ["min_range"=>1, "max_range"=>99]]) == true) { | |
| $this->id = $post['id']; | |
| $this->quantity = $post['quantity']; | |
| $article = $this->articledatabase->findByID($this->id); | |
| $this->cart->updateArticle($article, $this->quantity); | |
| header('Location: /cart'); | |
| } else { | |
| echo "Bitte gib eine valide Anzahl (1-99) der zu kaufenden Produkte an."; | |
| } | |
| } | |
| } |