Conditions | 3 |
Paths | 2 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
29 | 12 | public function __construct( \PDO $pdo, $table_name, ItemCodeInterface $itemcode = null, LoggerInterface $logger = null ) |
|
30 | { |
||
31 | 12 | $this->table_name = $table_name; |
|
32 | 12 | $this->pdo = $pdo; |
|
33 | 12 | $this->logger = $logger ?: new NullLogger; |
|
34 | |||
35 | $sql = "SELECT |
||
36 | -- This is the unique key |
||
37 | code, |
||
38 | -- and here the instance data |
||
39 | code, |
||
40 | name, |
||
41 | enabled, |
||
42 | display |
||
43 | 12 | FROM {$this->table_name} |
|
44 | WHERE 1"; |
||
45 | |||
46 | 12 | $stmt = $pdo->prepare($sql); |
|
47 | 12 | $stmt->setFetchMode( \PDO::FETCH_CLASS, $itemcode ? get_class($itemcode) : ItemCode::class ); |
|
48 | 12 | $stmt->execute(); |
|
49 | |||
50 | 12 | $this->item_codes = $stmt->fetchAll( \PDO::FETCH_UNIQUE ); |
|
51 | |||
52 | 12 | } |
|
53 | } |
||
54 |