Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
49 | public static function renderStatic( |
||
50 | array $arguments, |
||
51 | \Closure $renderChildrenClosure, |
||
52 | RenderingContextInterface $renderingContext |
||
53 | ): int { |
||
54 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
55 | ->getQueryBuilderForTable('tx_sfeventmgt_domain_model_event'); |
||
56 | |||
57 | $categoryUid = $arguments['categoryUid']; |
||
58 | $languageUid = GeneralUtility::makeInstance(Context::class)->getAspect('language')->getId(); |
||
59 | |||
60 | $count = $queryBuilder |
||
61 | ->count('tx_sfeventmgt_domain_model_event.title') |
||
62 | ->from('tx_sfeventmgt_domain_model_event') |
||
63 | ->rightJoin( |
||
64 | 'tx_sfeventmgt_domain_model_event', |
||
65 | 'sys_category_record_mm', |
||
66 | 'sys_category_record_mm', |
||
67 | $queryBuilder->expr()->eq('tx_sfeventmgt_domain_model_event.uid', $queryBuilder->quoteIdentifier('sys_category_record_mm.uid_foreign')) |
||
68 | ) |
||
69 | ->rightJoin( |
||
70 | 'sys_category_record_mm', |
||
71 | 'sys_category', |
||
72 | 'sys_category', |
||
73 | $queryBuilder->expr()->eq('sys_category.uid', $queryBuilder->quoteIdentifier('sys_category_record_mm.uid_local')) |
||
74 | ) |
||
75 | ->where( |
||
76 | $queryBuilder->expr()->andX( |
||
77 | $queryBuilder->expr()->eq( |
||
78 | 'sys_category.uid', |
||
79 | $queryBuilder->createNamedParameter($categoryUid, \PDO::PARAM_INT) |
||
80 | ), |
||
81 | $queryBuilder->expr()->eq( |
||
82 | 'sys_category_record_mm.tablenames', |
||
83 | $queryBuilder->createNamedParameter('tx_sfeventmgt_domain_model_event', \PDO::PARAM_STR) |
||
84 | ), |
||
85 | $queryBuilder->expr()->eq( |
||
86 | 'sys_category_record_mm.fieldname', |
||
87 | $queryBuilder->createNamedParameter('category', \PDO::PARAM_STR) |
||
88 | ) |
||
89 | , |
||
90 | $queryBuilder->expr()->in( |
||
91 | 'tx_sfeventmgt_domain_model_event.sys_language_uid', |
||
92 | $queryBuilder->createNamedParameter([-1, $languageUid], Connection::PARAM_INT_ARRAY) |
||
93 | ) |
||
94 | ) |
||
95 | ) |
||
96 | ->execute() |
||
97 | ->fetchColumn(0); |
||
98 | |||
99 | return $count; |
||
100 | } |
||
102 |