QueryAdapter::executeCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Agares\MicroORM;
5
6
final class QueryAdapter
7
{
8
    /**
9
     * @var DatabaseAdapterInterface
10
     */
11
    private $dbAdapter;
12
13
    /**
14
     * @var EntityMapperInterface
15
     */
16
    private $entityMapper;
17
18
    public function __construct(DatabaseAdapterInterface $dbAdapter, EntityMapperInterface $entityMapper)
19
    {
20
        $this->dbAdapter = $dbAdapter;
21
        $this->entityMapper = $entityMapper;
22
    }
23
24
    public function executeCommand($command, array $parameters = array())
25
    {
26
        $this->dbAdapter->executeCommand($command, $parameters);
27
    }
28
29
    public function executeQuery(string $query, EntityDefinition $entityDefinition, array $parameters = array())
30
    {
31
        $queryResult = $this->dbAdapter->executeQuery($query, $parameters);
32
        $entities = [];
33
        foreach($queryResult as $resultItem) {
34
            $entities[] = $this->entityMapper->map($resultItem, $entityDefinition);
35
        }
36
37
        return $entities;
38
    }
39
}