@@ -9,8 +9,6 @@ discard block |
||
9 | 9 | use Doctrine\Common\Util\ClassUtils; |
10 | 10 | use Doctrine\ORM\EntityManagerInterface; |
11 | 11 | use Doctrine\ORM\QueryBuilder; |
12 | -use Doctrine\ORM\Query as OrmQuery; |
|
13 | -use Doctrine\ORM\Tools\Pagination\Paginator; |
|
14 | 12 | use Psi\Component\ObjectAgent\AgentInterface; |
15 | 13 | use Psi\Component\ObjectAgent\Capabilities; |
16 | 14 | use Psi\Component\ObjectAgent\Exception\BadMethodCallException; |
@@ -18,7 +16,6 @@ discard block |
||
18 | 16 | use Psi\Component\ObjectAgent\Query\Comparison; |
19 | 17 | use Psi\Component\ObjectAgent\Query\Query; |
20 | 18 | use Psi\Component\ObjectAgent\Query\Join; |
21 | -use Doctrine\ORM\Query\Expr\Select; |
|
22 | 19 | |
23 | 20 | class OrmAgent implements AgentInterface |
24 | 21 | { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Psi\Bridge\ObjectAgent\Doctrine\Orm; |
6 | 6 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $idField = reset($idFields); |
104 | 104 | |
105 | 105 | $queryBuilder = $this->entityManager->getRepository($class)->createQueryBuilder('a'); |
106 | - $queryBuilder->where($queryBuilder->expr()->in('a.' . $idField, ':identifiers')); |
|
106 | + $queryBuilder->where($queryBuilder->expr()->in('a.'.$idField, ':identifiers')); |
|
107 | 107 | $queryBuilder->setParameter('identifiers', $identifiers); |
108 | 108 | |
109 | 109 | return $queryBuilder->getQuery()->execute(); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // TODO: Make a clone method on the Query, which allows passing an |
206 | 206 | // array of parts to replace in the clone. |
207 | 207 | $query = Query::create($query->getClassFqn(), [ |
208 | - 'selects' => [ 'count(' . self::SOURCE_ALIAS . '.' . $idField . ')' ], |
|
208 | + 'selects' => ['count('.self::SOURCE_ALIAS.'.'.$idField.')'], |
|
209 | 209 | 'joins' => $query->getJoins(), |
210 | 210 | 'criteria' => $query->hasExpression() ? $query->getExpression() : null, |
211 | 211 | ]); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | $selects = []; |
247 | 247 | foreach ($query->getSelects() as $selectName => $selectAlias) { |
248 | - $select = $selectName . ' ' . $selectAlias; |
|
248 | + $select = $selectName.' '.$selectAlias; |
|
249 | 249 | if (is_int($selectName)) { |
250 | 250 | $select = $selectAlias; |
251 | 251 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | foreach ($query->getOrderings() as $field => $order) { |
271 | - $queryBuilder->addOrderBy(self::SOURCE_ALIAS . '.' . $field, $order); |
|
271 | + $queryBuilder->addOrderBy(self::SOURCE_ALIAS.'.'.$field, $order); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | if (null !== $query->getFirstResult()) { |
@@ -60,6 +60,9 @@ |
||
60 | 60 | return new self($classFqn, $query['selects'], $query['joins'], $query['criteria'], $query['orderings'], $query['firstResult'], $query['maxResults']); |
61 | 61 | } |
62 | 62 | |
63 | + /** |
|
64 | + * @param string $value1 |
|
65 | + */ |
|
63 | 66 | public static function comparison(string $comparator, $value1, $value2): Comparison |
64 | 67 | { |
65 | 68 | return new Comparison($comparator, $value1, $value2); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Psi\Component\ObjectAgent\Query; |
6 | 6 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->joins = $joins; |
34 | 34 | $this->selects = $selects; |
35 | 35 | |
36 | - array_walk($joins, function (Join $join) { |
|
36 | + array_walk($joins, function(Join $join) { |
|
37 | 37 | }); |
38 | 38 | } |
39 | 39 |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'type' => Join::INNER_JOIN, |
68 | 68 | 'join'=> null, |
69 | 69 | 'alias' => null, |
70 | - ], $join, [ 'join', 'alias']); |
|
70 | + ], $join, ['join', 'alias']); |
|
71 | 71 | |
72 | 72 | $joinObjects[] = new Join($join['join'], $join['alias'], $join['type']); |
73 | 73 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | if ($diff = array_diff($required, array_keys($values))) { |
120 | 120 | throw new \InvalidArgumentException(sprintf( |
121 | 121 | 'Keys "%s" are required for "%s"', |
122 | - implode('", "', $diff), json_encode($values) |
|
122 | + implode('", "', $diff), json_encode($values) |
|
123 | 123 | )); |
124 | 124 | } |
125 | 125 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Psi\Bridge\ObjectAgent\Doctrine\Orm; |
6 | 6 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | return $this->walkComposite($expr); |
38 | 38 | } |
39 | 39 | |
40 | - throw new \RuntimeException('Unknown Expression: ' . get_class($expr)); |
|
40 | + throw new \RuntimeException('Unknown Expression: '.get_class($expr)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function getParameters() |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | return $this->expressionFactory->isNotNull($this->getField($field), $this->registerParameter($field, $value)); |
89 | 89 | } |
90 | 90 | |
91 | - throw new \RuntimeException('Unknown comparator: ' . $comparison->getComparator()); |
|
91 | + throw new \RuntimeException('Unknown comparator: '.$comparison->getComparator()); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | private function walkComposite(Composite $expression) |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $ormExpressions[] = $this->dispatch($childExpression); |
101 | 101 | } |
102 | 102 | |
103 | - $method = $expression->getType() == Composite::AND ? 'andX' : 'orX'; |
|
103 | + $method = $expression->getType() == Composite::AND? 'andX' : 'orX'; |
|
104 | 104 | |
105 | 105 | return call_user_func_array([$this->expressionFactory, $method], $ormExpressions); |
106 | 106 | } |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | // otherwise use the primary source alias. |
116 | - return $this->sourceAlias . '.' . $field; |
|
116 | + return $this->sourceAlias.'.'.$field; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | private function registerParameter(string $name, $value) |
120 | 120 | { |
121 | - $name = 'param' . $this->paramIndex++; |
|
121 | + $name = 'param'.$this->paramIndex++; |
|
122 | 122 | $this->parameters[$name] = $value; |
123 | 123 | |
124 | - return ':' . $name; |
|
124 | + return ':'.$name; |
|
125 | 125 | } |
126 | 126 | } |