| Conditions | 3 |
| Paths | 3 |
| Total Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 29 | public function handle(CriteriaConverter $converter, QueryBuilder $query, Criterion $criterion): string |
||
| 30 | { |
||
| 31 | $expr = $query->expr(); |
||
|
|
|||
| 32 | /*return $expr->in( |
||
| 33 | 'content.section_id', |
||
| 34 | $query->createNamedParameter((array)$criterion->value, Connection::PARAM_INT_ARRAY) |
||
| 35 | );*/ |
||
| 36 | |||
| 37 | /* @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion\UserMetadata $criterion */ |
||
| 38 | switch ($criterion->target) { |
||
| 39 | |||
| 40 | case Criterion\UserMetadata::MODIFIER: |
||
| 41 | $this->addInnerJoinIfNeeded( |
||
| 42 | $query, |
||
| 43 | 'content', |
||
| 44 | 'ezcontentobject_version', |
||
| 45 | 'version', |
||
| 46 | 'version.contentobject_id = content.id AND version.version = content.current_version' |
||
| 47 | ); |
||
| 48 | |||
| 49 | return $this->operateInt($query, 'version.creator_id', $criterion); |
||
| 50 | |||
| 51 | |||
| 52 | // @TODO Needed for permissions |
||
| 53 | /*case Criterion\UserMetadata::GROUP: |
||
| 54 | $subSelect = $query->subSelect(); |
||
| 55 | $subSelect |
||
| 56 | ->select( |
||
| 57 | $this->dbHandler->quoteColumn('contentobject_id', 't1') |
||
| 58 | )->from( |
||
| 59 | $query->alias( |
||
| 60 | $this->dbHandler->quoteTable('ezcontentobject_tree'), |
||
| 61 | 't1' |
||
| 62 | ) |
||
| 63 | )->innerJoin( |
||
| 64 | $query->alias( |
||
| 65 | $this->dbHandler->quoteTable('ezcontentobject_tree'), |
||
| 66 | 't2' |
||
| 67 | ), |
||
| 68 | $query->expr->like( |
||
| 69 | 't1.path_string', |
||
| 70 | $query->expr->concat( |
||
| 71 | 't2.path_string', |
||
| 72 | $query->bindValue('%') |
||
| 73 | ) |
||
| 74 | ) |
||
| 75 | )->where( |
||
| 76 | $query->expr->in( |
||
| 77 | $this->dbHandler->quoteColumn('contentobject_id', 't2'), |
||
| 78 | $criterion->value |
||
| 79 | ) |
||
| 80 | ); |
||
| 81 | |||
| 82 | return $query->expr->in( |
||
| 83 | $this->dbHandler->quoteColumn('owner_id', 'ezcontentobject'), |
||
| 84 | $subSelect |
||
| 85 | );*/ |
||
| 86 | |||
| 87 | case Criterion\UserMetadata::OWNER: |
||
| 88 | return $this->operateInt($query, 'content.owner_id', $criterion); |
||
| 89 | } |
||
| 90 | |||
| 91 | throw new RuntimeException("Invalid target criterion encountered:'" . $criterion->target . "'"); |
||
| 92 | } |
||
| 93 | } |
||
| 94 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.