Refactor, use a Collection

wip
This commit is contained in:
Oliver Davies 2020-02-09 14:27:12 +00:00
parent 9418ba4ee7
commit b773e0f76f
6 changed files with 174 additions and 80 deletions

View file

@ -11,6 +11,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Tightenco\Collect\Support\Collection;
class GenerateDrupal7Command extends Command
{
@ -85,7 +86,7 @@ class GenerateDrupal7Command extends Command
private function createFiles()
{
$createdFiles = [];
$createdFiles = new Collection();
/** @var SplFileInfo $file */
foreach ($this->finder->in('fixtures/drupal7_module')->name('/.[info,module]/') as $file) {
@ -96,10 +97,10 @@ class GenerateDrupal7Command extends Command
$contents
);
$createdFiles[] = "{$this->moduleName}.{$file->getExtension()}";
$createdFiles->push("{$this->moduleName}.{$file->getExtension()}");
}
$this->io->definitionList($createdFiles);
$this->io->listing($createdFiles->sort()->toArray());
}
private function updateFileContents($contents)

View file

@ -0,0 +1,17 @@
<?php
namespace Opdavies\DrupalModuleGenerator\Service;
class TestNameConverter
{
public function __invoke(string $moduleName)
{
$parts = explode('_', $moduleName);
$parts = array_map(function ($part) {
return ucfirst($part);
}, $parts);
return implode('', $parts).'Test';
}
}