Skip to content

Commit

Permalink
Merge pull request #60 from AydinHassan/code-cleanup
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
AydinHassan authored May 4, 2021
2 parents a75cef5 + 0a6a9fa commit 8f24252
Show file tree
Hide file tree
Showing 14 changed files with 331 additions and 633 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4, 8.0]
php: [8.0]

name: PHP ${{ matrix.php }}
steps:
Expand All @@ -33,6 +33,4 @@ jobs:
vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml
- name: Run phpcs
run: |
vendor/bin/phpcs --standard=PSR2 ./src/
vendor/bin/phpcs --standard=PSR2 ./test/
run: composer cs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
vendor
#composer.lock
.phpunit.result.cache
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"composer-plugin-api": "^2.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "~3.0",
"squizlabs/php_codesniffer": "^3.0",
"composer/composer": "^2.0",
"phpunit/phpunit": "^9.0",
"mikey179/vfsstream": "~1.4"
Expand All @@ -32,10 +32,14 @@
"extra": {
"class": "\\AydinHassan\\MagentoCoreComposerInstaller\\CoreManager"
},
"config": {
"platform-check": false,
"platform": {
"php": "8.0"
}
"scripts": {
"cs": [
"phpcs --standard=PSR12 ./src/",
"phpcs --standard=PSR12 ./test/"
],
"cs-fix": [
"phpcbf --standard=PSR12 ./src/",
"phpcbf --standard=PSR12 ./test/"
]
}
}
5 changes: 1 addition & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 4 additions & 47 deletions src/CoreInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,16 @@
namespace AydinHassan\MagentoCoreComposerInstaller;

use Composer\Util\Filesystem;
use ErrorException;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;

/**
* Class CoreInstaller
* @package AydinHassan\MagentoCoreComposerInstaller
* @author Aydin Hassan <aydin@hotmail.co.uk>
*/
class CoreInstaller
{

/**
* @var Exclude
*/
protected $exclude;

/**
* @var GitIgnore
*/
protected $gitIgnore;

/**
* @var Filesystem
*/
protected $fileSystem;

/**
* @param Exclude $exclude
* @param GitIgnore $gitIgnore
* @param Filesystem $fileSystem
*/
public function __construct(Exclude $exclude, GitIgnore $gitIgnore, Filesystem $fileSystem)
public function __construct(private Exclude $exclude, private GitIgnore $gitIgnore, private Filesystem $fileSystem)
{
$this->exclude = $exclude;
$this->gitIgnore = $gitIgnore;
$this->fileSystem = $fileSystem;
}

/**
* @param string $source
* @param string $destination
*/
public function install($source, $destination)
public function install(string $source, string $destination): void
{
$iterator = $this->getIterator($source, RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
Expand Down Expand Up @@ -80,11 +46,7 @@ public function install($source, $destination)
}
}

/**
* @param string $source
* @param string $destination
*/
public function unInstall($source, $destination)
public function unInstall(string $source, string $destination): void
{

$iterator = $this->getIterator($source, RecursiveIteratorIterator::CHILD_FIRST);
Expand Down Expand Up @@ -115,12 +77,7 @@ public function unInstall($source, $destination)
$this->gitIgnore->removeIgnoreDirectories();
}

/**
* @param string $source
* @param int $flags
* @return RecursiveIteratorIterator
*/
public function getIterator($source, $flags)
public function getIterator(string $source, int $flags): RecursiveIteratorIterator
{
return new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
Expand Down
Loading

0 comments on commit 8f24252

Please sign in to comment.