for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author stev leibelt <[email protected]>
* @since 2015-05-31
*/
namespace Net\Bazzline\Component\Locator\Process\Validator;
use Net\Bazzline\Component\Locator\Configuration\Configuration;
use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\ExecutableInterface;
class ConfigurationValidator implements ExecutableInterface
{
* @param array $input
* @return array
* @throws ExecutableException
public function execute($input = null)
if (!is_array($input)) {
throw new ExecutableException(
'input must be an array'
);
}
if (!($input['configuration'] instanceof Configuration)) {
'input must an instance of Configuration'
/** @var Configuration $configuration */
$configuration = $input['configuration'];
$path = $configuration->getFilePath();
if (is_file($path)) {
$message = 'provided path "' . $path . '" is an existing file';
throw new ExecutableException($message);
if (!is_dir($path)) {
$couldNotCreateNotExistingDirectory = !(mkdir($path));
if ($couldNotCreateNotExistingDirectory) {
$message = 'could not create directory "' . $path . '"';
if (!is_writable($path)) {
$message = 'provided directory "' . $path . '" is not writable';
return $input;