| Conditions | 4 |
| Paths | 12 |
| Total Lines | 52 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 47 | public function resolveForPackage(LinkedPackage $package): array |
||
| 48 | { |
||
| 49 | // TODO use configuration of original composer.json |
||
| 50 | $repositorySet = new RepositorySet( |
||
| 51 | 'dev', |
||
| 52 | [], |
||
| 53 | [], |
||
| 54 | ); |
||
| 55 | |||
| 56 | // TODO we can't use this |
||
| 57 | $exexutor = new ProcessExecutor($this->io); |
||
| 58 | $exexutor->enableAsync(); |
||
| 59 | |||
| 60 | // Fill repositories first the root package repository |
||
| 61 | $repositorySet->addRepository(new RootPackageRepository($this->composer->getPackage())); |
||
| 62 | |||
| 63 | // The locked repository, we don't do a full upgrade, so we want to keep as much as possible packages up to date |
||
| 64 | $repositorySet->addRepository($this->composer->getLocker()->getLockedRepository(true)); |
||
| 65 | |||
| 66 | // No we add our custom path repositories, we need to do this before we add the original repositories |
||
| 67 | // otherwise we do not get precedence over the other repositories |
||
| 68 | $repo = new PathRepository(['url' => $package->getPath()], $this->io, $this->composer->getConfig(), null, null, $exexutor); |
||
| 69 | $repositorySet->addRepository($repo); |
||
| 70 | |||
| 71 | // Add custom repositories defined in the composer file |
||
| 72 | $repositories = $this->composer->getRepositoryManager()->getRepositories(); |
||
| 73 | foreach ($repositories as $repository) { |
||
| 74 | $repositorySet->addRepository($repository); |
||
| 75 | } |
||
| 76 | |||
| 77 | // Make request for package, and fix all the currently existing packages |
||
| 78 | $request = new Request(); |
||
| 79 | $request->requireName($package->getName(), new Constraint('=', 'dev-master')); |
||
| 80 | foreach ($this->composer->getRepositoryManager()->getLocalRepository()->getPackages() as $localPackage) { |
||
| 81 | $request->fixPackage($localPackage); |
||
| 82 | } |
||
| 83 | $policy = new DefaultPolicy(true); |
||
| 84 | |||
| 85 | // Create pool and solve? |
||
| 86 | $pool = $repositorySet->createPool($request, $this->io); |
||
| 87 | $solver = new Solver($policy, $pool, $this->io); |
||
| 88 | |||
| 89 | $operations = []; |
||
| 90 | |||
| 91 | try { |
||
| 92 | $transaction = $solver->solve($request, PlatformRequirementFilterFactory::ignoreAll()); |
||
| 93 | $operations = $transaction->getOperations(); |
||
| 94 | } catch (SolverProblemsException $exception) { |
||
| 95 | $this->io->write($exception->getPrettyString($repositorySet, $request, $pool, true)); |
||
| 96 | } |
||
| 97 | |||
| 98 | return $operations; |
||
| 99 | } |
||
| 101 |