This repository has been archived by the owner on Jan 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from mikey179/master
incorporate new rootpath and resource loader
- Loading branch information
Showing
17 changed files
with
316 additions
and
184 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,57 @@ | ||
<?php | ||
/** | ||
* This file is part of stubbles. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package stubbles\console | ||
*/ | ||
namespace stubbles\console\creator; | ||
use stubbles\input\Filter; | ||
use stubbles\input\Param; | ||
/** | ||
* Filter for class names entered via user input. | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
class ClassNameFilter implements Filter | ||
{ | ||
/** | ||
* apply filter on given param | ||
* | ||
* @param Param $param | ||
* @return mixed filtered value | ||
*/ | ||
public function apply(Param $param) | ||
{ | ||
if ($param->isEmpty()) { | ||
$param->addError('CLASSNAME_EMPTY'); | ||
return null; | ||
} | ||
|
||
$className = str_replace('\\\\', '\\', trim($param->value())); | ||
if (! ((bool) preg_match('/^([a-zA-Z_]{1}[a-zA-Z0-9_\\\\]*)$/', $className))) { | ||
$param->addError('CLASSNAME_INVALID'); | ||
return null; | ||
} | ||
|
||
if (! (bool) preg_match('/^([a-zA-Z_]{1}[a-zA-Z0-9_]*)$/', $this->nonQualifiedClassNameOf($className))) { | ||
$param->addError('CLASSNAME_INVALID'); | ||
return null; | ||
} | ||
|
||
return $className; | ||
} | ||
|
||
/** | ||
* returns non qualified part of class name | ||
* | ||
* @param string $className | ||
* @return string | ||
*/ | ||
private function nonQualifiedClassNameOf($className) | ||
{ | ||
return substr($className, strrpos($className, '\\') + 1); | ||
} | ||
} |
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
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
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.