| Total Complexity | 4 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 59.09% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class AbstractQuery |
||
| 9 | { |
||
| 10 | protected $manager; |
||
| 11 | |||
| 12 | protected $entityName; |
||
| 13 | |||
| 14 | protected $entityAlias; |
||
| 15 | |||
| 16 | protected $parser; |
||
| 17 | |||
| 18 | 13 | public function __construct(EntityManager $manager) |
|
| 22 | 13 | } |
|
| 23 | |||
| 24 | public function createSelectAndGroupBy($entityName, $alias, $groupByField) |
||
| 25 | { |
||
| 26 | $select = $alias . '.' . $groupByField . ', count(' . $alias . '.id) as num'; |
||
| 27 | $groupBy = $alias . '.' . $groupByField . ''; |
||
| 28 | |||
| 29 | $this->entityName = $entityName; |
||
| 30 | $this->entityAlias = $alias; |
||
| 31 | |||
| 32 | $this->qBuilder = $this->manager->createQueryBuilder($this->entityName) |
||
| 33 | ->select($select) |
||
| 34 | ->groupBy($groupBy); |
||
| 35 | |||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 39 | 6 | public function createQueryBuilder($entityName, $alias) |
|
| 40 | { |
||
| 41 | 6 | $this->entityName = $entityName; |
|
| 42 | 6 | $this->entityAlias = $alias; |
|
| 43 | |||
| 44 | 6 | $this->qBuilder = $this->manager->createQueryBuilder($this->entityName) |
|
| 45 | 6 | ->select($alias) |
|
| 46 | 6 | ->from($this->entityName, $alias); |
|
| 47 | |||
| 48 | 6 | return $this; |
|
| 49 | } |
||
| 50 | |||
| 51 | 1 | public function getEntityName() |
|
| 54 | } |
||
| 55 | } |
||
| 56 |