PhpCsFixer\FixerNameValidator::isValid PHP Method

isValid() public method

public isValid ( strnig $name, boolean $isCustom ) : boolean
$name strnig
$isCustom boolean
return boolean
    public function isValid($name, $isCustom)
    {
        if (!$isCustom) {
            return 1 === preg_match('/^[a-z][a-z0-9_]*$/', $name);
        }
        return 1 === preg_match('/^[A-Z][a-zA-Z0-9]*\\/[a-z][a-z0-9_]*$/', $name);
    }

Usage Example

 /**
  * Register fixer.
  *
  * @param FixerInterface $fixer
  * @param bool           $isCustom
  *
  * @return $this
  */
 public function registerFixer(FixerInterface $fixer, $isCustom)
 {
     $name = $fixer->getName();
     if (isset($this->fixersByName[$name])) {
         throw new \UnexpectedValueException(sprintf('Fixer named "%s" is already registered.', $name));
     }
     if (!$this->nameValidator->isValid($name, $isCustom)) {
         throw new \UnexpectedValueException(sprintf('Fixer named "%s" has invalid name.', $name));
     }
     $this->fixers[] = $fixer;
     $this->fixersByName[$name] = $fixer;
     return $this;
 }
FixerNameValidator