Skip to content

Commit 27bfc5f

Browse files
committed
Added first tests and minor refactorings
1 parent 0121a93 commit 27bfc5f

16 files changed

+305
-121
lines changed

src/Command/Recipes/RecipeRepoManagerCommand.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@
2525
* @package App\Command\Recipes
2626
* @author moay <[email protected]>
2727
*/
28-
abstract class RecipeRepoManagerCommand extends Command implements RecipeRepoManagerCommandInterface
28+
abstract class RecipeRepoManagerCommand extends Command
2929
{
3030
const ACTION_NAMESPACE = 'recipes:';
3131

3232
/** @var RecipeRepoManager */
3333
private $repoManager;
3434

35+
/** @var string */
36+
protected $action;
37+
38+
/** @var string */
39+
protected $description;
40+
3541
/**
3642
* RecipesInitializeCommand constructor.
3743
* @param RecipeRepoManager $repoManager
@@ -46,13 +52,13 @@ public function __construct(RecipeRepoManager $repoManager)
4652
protected function configure()
4753
{
4854
$this
49-
->setName(self::ACTION_NAMESPACE . $this->getAction())
50-
->setDescription($this->getDescription());
55+
->setName(self::ACTION_NAMESPACE . $this->action)
56+
->setDescription($this->description);
5157

5258
$description = sprintf(
5359
'%s a single repo by selecting \'private\', \'official\' or \'contrib\'. Don\'t select any in order to %s all configured repos.',
54-
ucfirst($this->getAction()),
55-
$this->getAction()
60+
ucfirst($this->action),
61+
$this->action
5662
);
5763

5864
$this->addArgument('repo', InputArgument::IS_ARRAY, $description, []);
@@ -83,8 +89,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
8389
} else {
8490
if ($this->repoManager->isConfiguredByDirName($repo)) {
8591
try {
86-
$this->repoManager->executeOnRepo($this->getAction(), $repo);
87-
$actionPast = $this->getAction() == 'reset' ? 'resetted' : $this->getAction() . 'd';
92+
$this->repoManager->executeOnRepo($this->action, $repo);
93+
$actionPast = $this->action === 'reset' ? 'resetted' : $this->action . 'd';
8894
$io->success(sprintf('%s recipes repo %s.', ucfirst($repo), $actionPast));
8995
} catch (RecipeRepoManagerException $e) {
9096
$io->error($e->getMessage());
@@ -94,6 +100,5 @@ protected function execute(InputInterface $input, OutputInterface $output)
94100
}
95101
}
96102
}
97-
98103
}
99104
}

src/Command/Recipes/RecipeRepoManagerCommandInterface.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Command/Recipes/RecipesInitializeCommand.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,9 @@
1919
class RecipesInitializeCommand extends RecipeRepoManagerCommand
2020
{
2121
/** @var string */
22-
private $action = 'initialize';
22+
protected $action = 'initialize';
2323

2424
/** @var string */
25-
private $description = 'Initializes local recipe repos from remote repo';
25+
protected $description = 'Initializes local recipe repos from remote repo';
2626

27-
/**
28-
* @return string
29-
*/
30-
public function getAction()
31-
{
32-
return $this->action;
33-
}
34-
35-
/**
36-
* @return string
37-
*/
38-
public function getDescription()
39-
{
40-
return $this->description;
41-
}
4227
}

src/Command/Recipes/RecipesRemoveCommand.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,8 @@
1919
class RecipesRemoveCommand extends RecipeRepoManagerCommand
2020
{
2121
/** @var string */
22-
private $action = 'remove';
22+
protected $action = 'remove';
2323

2424
/** @var string */
25-
private $description = 'Deletes local recipe repos';
26-
27-
/**
28-
* @return string
29-
*/
30-
public function getAction()
31-
{
32-
return $this->action;
33-
}
34-
35-
/**
36-
* @return string
37-
*/
38-
public function getDescription()
39-
{
40-
return $this->description;
41-
}
25+
protected $description = 'Deletes local recipe repos';
4226
}

src/Command/Recipes/RecipesResetCommand.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,8 @@
1919
class RecipesResetCommand extends RecipeRepoManagerCommand
2020
{
2121
/** @var string */
22-
private $action = 'reset';
22+
protected $action = 'reset';
2323

2424
/** @var string */
25-
private $description = 'Resets local recipe repos by deleting and reinitalizing from remote repo';
26-
27-
/**
28-
* @return string
29-
*/
30-
public function getAction()
31-
{
32-
return $this->action;
33-
}
34-
35-
/**
36-
* @return string
37-
*/
38-
public function getDescription()
39-
{
40-
return $this->description;
41-
}
25+
protected $description = 'Resets local recipe repos by deleting and reinitalizing from remote repo';
4226
}

src/Command/Recipes/RecipesUpdateCommand.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,8 @@
1919
class RecipesUpdateCommand extends RecipeRepoManagerCommand
2020
{
2121
/** @var string */
22-
private $action = 'update';
22+
protected $action = 'update';
2323

2424
/** @var string */
25-
private $description = 'Updates local recipe repos to match the current remote repo';
26-
27-
/**
28-
* @return string
29-
*/
30-
public function getAction()
31-
{
32-
return $this->action;
33-
}
34-
35-
/**
36-
* @return string
37-
*/
38-
public function getDescription()
39-
{
40-
return $this->description;
41-
}
25+
protected $description = 'Updates local recipe repos to match the current remote repo';
4226
}

src/Command/System/SystemStatusCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public function configure()
4545
->setDescription('Provides an overview over the system status');
4646
}
4747

48+
/**
49+
* @param InputInterface $input
50+
* @param OutputInterface $output
51+
* @return void
52+
*/
4853
public function execute(InputInterface $input, OutputInterface $output)
4954
{
5055
$io = new SymfonyStyle($input, $output);

src/Service/Compiler/LocalRecipeCompiler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ public function __construct(RecipeRepoManager $repoManager)
4343
/**
4444
* @return Recipe[]
4545
*/
46-
public function getLocalRecipes() {
46+
public function getLocalRecipes()
47+
{
4748
if (count($this->recipes) == 0) {
48-
$this->loadLocalRecipes();
49+
$this->loadLocalRecipes();
4950
}
5051

5152
return $this->recipes;

src/Service/Compiler/PackagesCompiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function getPackageLocks(array $requestedPackages)
4343
{
4444
$locks = [];
4545
foreach ($requestedPackages as $package) {
46-
$locks[join('/', [$package['author'], $package['package']])] = ['version' => $package['version']];
46+
$locks[implode('/', [$package['author'], $package['package']])] = ['version' => $package['version']];
4747
}
4848
return $locks;
4949
}
@@ -65,7 +65,7 @@ private function getManifests(array $localRecipes, array $officialResponse)
6565
'files' => $this->getRecipeFiles($recipe),
6666
'origin' => $recipe->getOfficialPackageName() . ':' . $recipe->getVersion() . '@private:master',
6767
'not_installable' => $recipe->isManifestValid() === false,
68-
'is_contrib' => $recipe->getRepoSlug() == 'contrib'
68+
'is_contrib' => $recipe->getRepoSlug() === 'contrib'
6969
];
7070

7171
if (empty($manifest['files'])) {

src/Service/OfficialEndpointProxy.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function __construct(
5858
* Provides a proxy for the aliases.json call, which provides official Symfony aliases.
5959
*
6060
* @return array
61+
* @throws \Exception
62+
* @throws \Http\Client\Exception
6163
*/
6264
public function getAliases()
6365
{
@@ -69,6 +71,8 @@ public function getAliases()
6971
* Provides a proxy for the versions.json call, which provides version information for Symfony.
7072
*
7173
* @return array
74+
* @throws \Exception
75+
* @throws \Http\Client\Exception
7276
*/
7377
public function getVersions()
7478
{
@@ -81,6 +85,8 @@ public function getVersions()
8185
*
8286
* @param string $packagesRequestString
8387
* @return array|string
88+
* @throws \Exception
89+
* @throws \Http\Client\Exception
8490
*/
8591
public function getPackages(string $packagesRequestString)
8692
{
@@ -91,6 +97,8 @@ public function getPackages(string $packagesRequestString)
9197
/**
9298
* @param Request $request
9399
* @return array|string
100+
* @throws \Exception
101+
* @throws \Http\Client\Exception
94102
*/
95103
private function getDecodedResponse(Request $request)
96104
{

0 commit comments

Comments
 (0)