| Code Coverage | ||||||||||
| Classes and Traits | Functions and Methods | Lines | ||||||||
| Total |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 4 | CRAP |  | 0.00% | 0 / 19 | 
| App\Models\ArticleDatabase |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 4 | 20 |  | 0.00% | 0 / 19 | 
| __construct |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 2 | |||
| findByID |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 7 | |||
| findByName |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 6 | |||
| findAll |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 4 | |||
| <?php | |
| namespace App\Models; | |
| use App\Models\DatabaseMySql; | |
| use App\Models\ArticleFactory; | |
| class ArticleDatabase { | |
| private $db; | |
| public function __construct() { | |
| $this->db = DatabaseMySql::getInstance(); | |
| } | |
| /** | |
| * | |
| * @param $id | |
| * @return array | |
| */ | |
| public function findByID($id) { | |
| $return = $this->db->queryWithFactory( | |
| 'Select * from article where id = :id', new ArticleFactory(), [ | |
| "id" => $id | |
| ] | |
| ); | |
| return array_shift($return); | |
| } | |
| /** | |
| * | |
| * @param string $name | |
| * @return array | |
| */ | |
| public function findByName($name) { | |
| return $this->db->queryWithFactory( | |
| 'Select * from article where name = :name', new ArticleFactory(), [ | |
| 'name' => $name | |
| ] | |
| ); | |
| } | |
| /** | |
| * | |
| * @return array | |
| */ | |
| public function findAll() { | |
| return $this->db->queryWithFactory( | |
| 'Select * from article', new ArticleFactory(), [] | |
| ); | |
| } | |
| } |