forked from php-pds/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored validator to support more cli commands. Added bin to paren…
…t project.
- Loading branch information
Showing
7 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env php | ||
|
||
<?php | ||
|
||
$autoloadFiles = [ | ||
__DIR__ . '/../vendor/autoload.php', | ||
__DIR__ . '/../../../autoload.php' | ||
]; | ||
|
||
foreach ($autoloadFiles as $autoloadFile) { | ||
if (file_exists($autoloadFile)) { | ||
require_once $autoloadFile; | ||
break; | ||
} | ||
} | ||
|
||
use PDS\Skeleton\Console; | ||
|
||
$console = new Console(); | ||
$console->execute($argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace PDS\Skeleton; | ||
|
||
class Console | ||
{ | ||
protected $commandsWhitelist = [ | ||
'validate' => 'PDS\Skeleton\ComplianceValidator', | ||
]; | ||
|
||
public function execute($args) | ||
{ | ||
if (count($args) > 1) { | ||
|
||
$executable = array_shift($args); | ||
$commandName = array_shift($args); | ||
|
||
if (array_key_exists($commandName, $this->commandsWhitelist)) { | ||
return $this->executeCommand($this->commandsWhitelist[$commandName], $args); | ||
} | ||
|
||
$this->outputHelp(); | ||
return false; | ||
} | ||
|
||
$this->outputHelp(); | ||
return false; | ||
} | ||
|
||
protected function executeCommand($commandClass, $args) | ||
{ | ||
$command = new $commandClass(); | ||
return $command->execute($args); | ||
} | ||
|
||
protected function outputHelp() | ||
{ | ||
echo 'Available commands:' . PHP_EOL; | ||
foreach ($this->commandsWhitelist as $key => $value) { | ||
echo 'pdsskeleton ' . $key . PHP_EOL; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters