| Conditions | 8 | 
| Paths | 73 | 
| Total Lines | 70 | 
| 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  | 
            ||
| 27 | public function batchConfigureAcls(OutputInterface $output, AdminInterface $admin, ?UserSecurityIdentity $securityIdentity = null): void  | 
            ||
| 28 |     { | 
            ||
| 29 | $securityHandler = $admin->getSecurityHandler();  | 
            ||
| 30 |         if (!$securityHandler instanceof AclSecurityHandlerInterface) { | 
            ||
| 31 |             $output->writeln('Admin class is not configured to use ACL : <info>ignoring</info>'); | 
            ||
| 32 | |||
| 33 | return;  | 
            ||
| 34 | }  | 
            ||
| 35 | |||
| 36 |         $output->writeln(sprintf(' > generate ACLs for %s', $admin->getCode())); | 
            ||
| 37 | $objectOwnersMsg = null === $securityIdentity ? '' : ' and set the object owner';  | 
            ||
| 38 | |||
| 39 | /** @var DocumentManager $om */  | 
            ||
| 40 | $om = $admin->getModelManager()->getDocumentManager();  | 
            ||
| 41 | $qb = $om->createQueryBuilder($admin->getClass());  | 
            ||
| 42 | |||
| 43 | $count = 0;  | 
            ||
| 44 | $countUpdated = 0;  | 
            ||
| 45 | $countAdded = 0;  | 
            ||
| 46 | |||
| 47 |         try { | 
            ||
| 48 | $batchSize = 20;  | 
            ||
| 49 | $batchSizeOutput = 200;  | 
            ||
| 50 | $objectIds = [];  | 
            ||
| 51 | $objectIdIterator = new \ArrayIterator();  | 
            ||
| 52 | |||
| 53 |             foreach ($qb->getQuery()->iterate() as $row) { | 
            ||
| 54 | $objectIds[] = ObjectIdentity::fromDomainObject($row);  | 
            ||
| 55 | $objectIdIterator = new \ArrayIterator($objectIds);  | 
            ||
| 56 | |||
| 57 | // detach from Doctrine, so that it can be Garbage-Collected immediately  | 
            ||
| 58 | $om->detach($row);  | 
            ||
| 59 | |||
| 60 | ++$count;  | 
            ||
| 61 | |||
| 62 |                 if (0 === ($count % $batchSize)) { | 
            ||
| 63 | [$batchAdded, $batchUpdated] = $this->configureAcls($output, $admin, $objectIdIterator, $securityIdentity);  | 
            ||
| 64 | $countAdded += $batchAdded;  | 
            ||
| 65 | $countUpdated += $batchUpdated;  | 
            ||
| 66 | $objectIds = [];  | 
            ||
| 67 | }  | 
            ||
| 68 | |||
| 69 |                 if (0 === ($count % $batchSizeOutput)) { | 
            ||
| 70 | $output->writeln(sprintf(  | 
            ||
| 71 | ' - generated class ACEs%s for %s objects (added %s, updated %s)',  | 
            ||
| 72 | $objectOwnersMsg,  | 
            ||
| 73 | $count,  | 
            ||
| 74 | $countAdded,  | 
            ||
| 75 | $countUpdated  | 
            ||
| 76 | ));  | 
            ||
| 77 | }  | 
            ||
| 78 | }  | 
            ||
| 79 | |||
| 80 |             if (\count($objectIds) > 0) { | 
            ||
| 81 | [$batchAdded, $batchUpdated] = $this->configureAcls($output, $admin, $objectIdIterator, $securityIdentity);  | 
            ||
| 82 | $countAdded += $batchAdded;  | 
            ||
| 83 | $countUpdated += $batchUpdated;  | 
            ||
| 84 | }  | 
            ||
| 85 |         } catch (\BadMethodCallException $e) { | 
            ||
| 86 |             throw new ModelManagerException('', 0, $e); | 
            ||
| 87 | }  | 
            ||
| 88 | |||
| 89 | $output->writeln(sprintf(  | 
            ||
| 90 | ' - [TOTAL] generated class ACEs%s for %s objects (added %s, updated %s)',  | 
            ||
| 91 | $objectOwnersMsg,  | 
            ||
| 92 | $count,  | 
            ||
| 93 | $countAdded,  | 
            ||
| 94 | $countUpdated  | 
            ||
| 95 | ));  | 
            ||
| 96 | }  | 
            ||
| 97 | }  | 
            ||
| 98 | 
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.