ElggPluginManifest::normalizeDep PHP Méthode

normalizeDep() private méthode

Can be used with either requires or suggests.
private normalizeDep ( array $dep ) : array
$dep array A dependency array.
Résultat array The normalized deps array.
    private function normalizeDep($dep)
    {
        switch ($dep['type']) {
            case 'elgg_release':
                $struct = $this->depsStructElgg;
                break;
            case 'plugin':
                $struct = $this->depsStructPlugin;
                break;
            case 'priority':
                $struct = $this->depsStructPriority;
                break;
            case 'php_version':
                $struct = $this->depsStructPhpVersion;
                break;
            case 'php_extension':
                $struct = $this->depsStructPhpExtension;
                break;
            case 'php_ini':
                $struct = $this->depsStructPhpIni;
                // also normalize boolean values
                if (isset($dep['value'])) {
                    switch (strtolower($dep['value'])) {
                        case 'yes':
                        case 'true':
                        case 'on':
                        case 1:
                            $dep['value'] = 1;
                            break;
                        case 'no':
                        case 'false':
                        case 'off':
                        case 0:
                        case '':
                            $dep['value'] = 0;
                            break;
                    }
                }
                break;
            default:
                // unrecognized so we just return the raw dependency
                return $dep;
        }
        // @todo $struct may not have been defined...
        $normalized_dep = $this->buildStruct($struct, $dep);
        // normalize comparison operators
        if (isset($normalized_dep['comparison'])) {
            switch ($normalized_dep['comparison']) {
                case '<':
                    $normalized_dep['comparison'] = 'lt';
                    break;
                case '<=':
                    $normalized_dep['comparison'] = 'le';
                    break;
                case '>':
                    $normalized_dep['comparison'] = 'gt';
                    break;
                case '>=':
                    $normalized_dep['comparison'] = 'ge';
                    break;
                case '==':
                case 'eq':
                    $normalized_dep['comparison'] = '=';
                    break;
                case '<>':
                case 'ne':
                    $normalized_dep['comparison'] = '!=';
                    break;
            }
        }
        return $normalized_dep;
    }