Ejemplo n.º 1
0
 /**
  * @param $variableName
  * @throws \InvalidArgumentException
  */
 public function __construct($variableName)
 {
     if (true === ReservedKeyword::isValid($variableName)) {
         throw new \InvalidArgumentException(sprintf('Variable name can not contain reserved keyword : %s', $variableName));
     }
     if (false === (bool) preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $variableName)) {
         throw new \InvalidArgumentException($variableName . ' do not respect php standard name format');
     }
     $this->magicPrefix = 0 === strpos($variableName, '__');
     $this->variableName = $variableName;
     $this->splitedName = $this->splitName($variableName);
 }
 /**
  * @param string $className
  * @throws \InvalidArgumentException
  */
 public function __construct($className)
 {
     $splitedClassName = explode('\\', $className);
     $lastKey = count($splitedClassName) - 1;
     $this->className = new PhpVariableName($splitedClassName[$lastKey]);
     unset($splitedClassName[$lastKey]);
     array_walk($splitedClassName, function ($val) use($className) {
         if (true === ReservedKeyword::isValid($val)) {
             throw new \InvalidArgumentException(sprintf('Namespace can not contain reserved keyword, %s find in %s', $val, $className));
         }
     });
     $this->namespace = $splitedClassName;
 }