Gush\Util\StringUtil::concatWords PHP Method

concatWords() public static method

Converts 'git flow', 'git-flow' and 'git_flow' to 'GitFlow'.
public static concatWords ( string $word ) : string
$word string The word to transform.
return string The transformed word.
    public static function concatWords(string $word) : string
    {
        return str_replace([' ', '-', '_'], '', ucwords($word, '_- '));
    }

Usage Example

 public function validate($source, $target)
 {
     $validateBranches = count($this->branches) > 1;
     if (self::PRESET_NONE !== $this->preset) {
         $preset = 'preset' . StringUtil::concatWords($this->preset);
         // When the policy is deny-merge for unknown branches
         // the preset is used as primary, if it grants access then branches are not checked,
         // else you would need configure branches for all checks!
         if (true === $this->{$preset}($source, $target)) {
             $validateBranches = self::BRANCH_POLICY_DENY === $this->policy ? false : $validateBranches;
         }
     }
     if ($validateBranches) {
         $this->validateBranches($source, $target, $this->branches, $this->policy);
     }
     return true;
 }