PHPComposter\PHPComposter\HookConfig::getEntries PHP Method

getEntries() public static method

Get the entries for a given Git hook.
Since: 0.1.0
public static getEntries ( string $hook ) : array
$hook string Git hook to retrieve the methods for.
return array Array of fully qualified method names. Empty array if none.
    public static function getEntries($hook)
    {
        if (array_key_exists($hook, static::$config)) {
            return static::$config[$hook];
        }
        return array();
    }

Usage Example

Example #1
0
 /**
  * Generate the config file.
  *
  * @since 0.1.0
  *
  * @return string Generated Config file.
  */
 public static function getConfig()
 {
     $output = '<?php' . PHP_EOL;
     $output .= '// PHP Composter configuration file.' . PHP_EOL;
     $output .= '// Do not edit, this file is generated automatically.' . PHP_EOL;
     $output .= '// Timestamp: ' . date('Y/m/d H:m:s') . PHP_EOL;
     $output .= PHP_EOL;
     $output .= 'return array(' . PHP_EOL;
     foreach (static::getGitHookNames() as $hook) {
         $entries = HookConfig::getEntries($hook);
         $output .= '    \'' . $hook . '\' => array(' . PHP_EOL;
         foreach ($entries as $priority => $methods) {
             $output .= '        ' . $priority . ' => array(' . PHP_EOL;
             foreach ($methods as $method) {
                 $output .= '            \'' . $method . '\',' . PHP_EOL;
             }
             $output .= '        ),' . PHP_EOL;
         }
         $output .= '    ),' . PHP_EOL;
     }
     $output .= ');' . PHP_EOL;
     return $output;
 }