public static function getValidHooks($dir)
    {
        $composerFile = "{$dir}/composer.json";
        if (!file_exists($composerFile)) {
            return [];
        }

        $contents = file_get_contents($composerFile);
        $json = json_decode($contents, true);
        $hooks = array_merge(
            isset($json['scripts']) ? $json['scripts'] : [],
            isset($json['hooks']) ? $json['hooks'] : [],
            isset($json['extra']['hooks']) ? $json['extra']['hooks'] : []
        );
        $validHooks = [];

        foreach ($hooks as $hook => $script) {
            if (self::isValidHook($hook)) {
                $validHooks[$hook] = $script;
            }
        }

        return $validHooks;
    }
public static function getValidHooks($dir)
    {
        $composerFile = "{$dir}/composer.json";
        if (!file_exists($composerFile)) {
            return [];
        }

        $contents = file_get_contents($composerFile);
        $json = json_decode($contents, true);
        $hooks = array_merge(
            isset($json['scripts']) ? $json['scripts'] : [],
            isset($json['hooks']) ? $json['hooks'] : [],
            isset($json['extra']['hooks']) ? $json['extra']['hooks'] : []
        );
        $validHooks = [];

        foreach ($hooks as $hook => $script) {
            if (self::isValidHook($hook)) {
                $validHooks[$hook] = $script;
            }
        }

        return $validHooks;
    }
public static function getValidHooks ( $ dir ) { $ composerFile = "{$dir}/composer.json" ; if ( ! file_exists ( $ composerFile ) ) { return [ ] ; } $ contents = file_get_contents ( $ composerFile ) ; $ json = json_decode ( $ contents , true ) ; $ hooks = array_merge ( isset ( $ json [ 'scripts' ] ) ? $ json [ 'scripts' ] : [ ] , isset ( $ json [ 'hooks' ] ) ? $ json [ 'hooks' ] : [ ] , isset ( $ json [ 'extra' ] [ 'hooks' ] ) ? $ json [ 'extra' ] [ 'hooks' ] : [ ] ) ; $ validHooks = [ ] ; foreach ( $ hooks as $ hook => $ script ) { if ( self :: isValidHook ( $ hook ) ) { $ validHooks [ $ hook ] = $ script ; } } return $ validHooks ; }
Get scripts section of the composer config file.

@param	$dir	string	dir where to look for composer.json

@return array
Get scripts section of the composer config file .