Closed bfontaine closed 3 years ago
This would require some sort of alias
method.
$test = new \Gajus\Vlad\Test();
$test->alias('My\Long\Namespace\Base64', 'Base64');
$test->assert('foo')->is('Base64');
The problem with the above is that as long as alias is Test specific, it is not much useful.
Alternatively, Test
could lookup up static variable, e.g.
\Gajus\Vlad\Test::alias('My\Long\Namespace\Base64', 'Base64');
$test = new \Gajus\Vlad\Test();
$test->assert('foo')->is('Base64');
The problem with the above is that it would introduce a global state.
Final alternative would be to have user land class that defines those aliases, e.g.
class MyTest extends \Gajus\Vlad\Test {
public function __construct (\Gajus\Vlad\Translator $translator = null) {
parent::__construct($translator);
$this->alias('My\Long\Namespace\Base64', 'Base64');
}
}
Let validators declare a keyword to be called with instead of their full namespaced-name, e.g.:
instead of: