src/Joli/JoliCi/BuildStrategy/TravisCiBuildStrategy.php
protected function createMatrix($config)
    {
        $language = isset($config['language']) ? $config['language'] : 'ruby';

        if (!isset($this->defaults[$language])) {
            throw new \Exception(sprintf('Language %s not supported', $language));
        }

        $versionKey       = isset($this->languageVersionKeyMapping[$language]) ? $this->languageVersionKeyMapping[$language] : $language;
        $environmentLines = $this->getConfigValue($config, $language, "env");
        $environnements   = array();
        $globalEnv        = array();
        $matrixEnv        = $environmentLines;
        $versions         = (array) (isset($config[$versionKey]) ? $config[$versionKey] : $this->defaults[$language]['default_versions']);

        foreach ($versions as $key => $version) {
            if (!$this->isLanguageVersionSupported($language, $version)) {
                unset($versions[$key]);
            }
        }

        if (isset($environmentLines['matrix'])) {
            $matrixEnv = $environmentLines['matrix'];
        }

        if (isset($environmentLines['global'])) {
            foreach ($environmentLines['global'] as $environementVariable) {
                if (is_array($environementVariable) && array_key_exists('secure', $environementVariable)) {
                    continue;
                }

                list ($key, $value) = $this->parseEnvironementVariable($environementVariable);
                $globalEnv = array_merge($globalEnv, array($key => $value));
            }

            if (!isset($environmentLines['matrix'])) {
                $matrixEnv = array();
            }
        }

        // Parsing environnements
        foreach ($matrixEnv as $environmentLine) {
            $environnements[] = $this->parseEnvironmentLine($environmentLine);
        }

        $matrix = new Matrix();
        $matrix->setDimension('language', array($language));
        $matrix->setDimension('environment', $environnements);
        $matrix->setDimension('global_env', array($globalEnv));
        $matrix->setDimension('version', $versions);
        $matrix->setDimension('before_install', array($this->getConfigValue($config, $language, 'before_install')));
        $matrix->setDimension('install', array($this->getConfigValue($config, $language, 'install')));
        $matrix->setDimension('before_script', array($this->getConfigValue($config, $language, 'before_script')));
        $matrix->setDimension('script', array($this->getConfigValue($config, $language, 'script')));


        return $matrix;
    }
protected function createMatrix($config)
    {
        $language = isset($config['language']) ? $config['language'] : 'ruby';

        if (!isset($this->defaults[$language])) {
            throw new \Exception(sprintf('Language %s not supported', $language));
        }

        $versionKey       = isset($this->languageVersionKeyMapping[$language]) ? $this->languageVersionKeyMapping[$language] : $language;
        $environmentLines = $this->getConfigValue($config, $language, "env");
        $environnements   = array();
        $globalEnv        = array();
        $matrixEnv        = $environmentLines;
        $versions         = (array) (isset($config[$versionKey]) ? $config[$versionKey] : $this->defaults[$language]['default_versions']);

        foreach ($versions as $key => $version) {
            if (!$this->isLanguageVersionSupported($language, $version)) {
                unset($versions[$key]);
            }
        }

        if (isset($environmentLines['matrix'])) {
            $matrixEnv = $environmentLines['matrix'];
        }

        if (isset($environmentLines['global'])) {
            foreach ($environmentLines['global'] as $environementVariable) {
                if (is_array($environementVariable) && array_key_exists('secure', $environementVariable)) {
                    continue;
                }

                list ($key, $value) = $this->parseEnvironementVariable($environementVariable);
                $globalEnv = array_merge($globalEnv, array($key => $value));
            }

            if (!isset($environmentLines['matrix'])) {
                $matrixEnv = array();
            }
        }

        // Parsing environnements
        foreach ($matrixEnv as $environmentLine) {
            $environnements[] = $this->parseEnvironmentLine($environmentLine);
        }

        $matrix = new Matrix();
        $matrix->setDimension('language', array($language));
        $matrix->setDimension('environment', $environnements);
        $matrix->setDimension('global_env', array($globalEnv));
        $matrix->setDimension('version', $versions);
        $matrix->setDimension('before_install', array($this->getConfigValue($config, $language, 'before_install')));
        $matrix->setDimension('install', array($this->getConfigValue($config, $language, 'install')));
        $matrix->setDimension('before_script', array($this->getConfigValue($config, $language, 'before_script')));
        $matrix->setDimension('script', array($this->getConfigValue($config, $language, 'script')));


        return $matrix;
    }
protected function createMatrix ( $ config ) { $ language = isset ( $ config [ 'language' ] ) ? $ config [ 'language' ] : 'ruby' ; if ( ! isset ( $ this -> defaults [ $ language ] ) ) { throw new \ Exception ( sprintf ( 'Language %s not supported' , $ language ) ) ; } $ versionKey = isset ( $ this -> languageVersionKeyMapping [ $ language ] ) ? $ this -> languageVersionKeyMapping [ $ language ] : $ language ; $ environmentLines = $ this -> getConfigValue ( $ config , $ language , "env" ) ; $ environnements = array ( ) ; $ globalEnv = array ( ) ; $ matrixEnv = $ environmentLines ; $ versions = ( array ) ( isset ( $ config [ $ versionKey ] ) ? $ config [ $ versionKey ] : $ this -> defaults [ $ language ] [ 'default_versions' ] ) ; foreach ( $ versions as $ key => $ version ) { if ( ! $ this -> isLanguageVersionSupported ( $ language , $ version ) ) { unset ( $ versions [ $ key ] ) ; } } if ( isset ( $ environmentLines [ 'matrix' ] ) ) { $ matrixEnv = $ environmentLines [ 'matrix' ] ; } if ( isset ( $ environmentLines [ 'global' ] ) ) { foreach ( $ environmentLines [ 'global' ] as $ environementVariable ) { if ( is_array ( $ environementVariable ) && array_key_exists ( 'secure' , $ environementVariable ) ) { continue ; } list ( $ key , $ value ) = $ this -> parseEnvironementVariable ( $ environementVariable ) ; $ globalEnv = array_merge ( $ globalEnv , array ( $ key => $ value ) ) ; } if ( ! isset ( $ environmentLines [ 'matrix' ] ) ) { $ matrixEnv = array ( ) ; } } // Parsing environnements foreach ( $ matrixEnv as $ environmentLine ) { $ environnements [ ] = $ this -> parseEnvironmentLine ( $ environmentLine ) ; } $ matrix = new Matrix ( ) ; $ matrix -> setDimension ( 'language' , array ( $ language ) ) ; $ matrix -> setDimension ( 'environment' , $ environnements ) ; $ matrix -> setDimension ( 'global_env' , array ( $ globalEnv ) ) ; $ matrix -> setDimension ( 'version' , $ versions ) ; $ matrix -> setDimension ( 'before_install' , array ( $ this -> getConfigValue ( $ config , $ language , 'before_install' ) ) ) ; $ matrix -> setDimension ( 'install' , array ( $ this -> getConfigValue ( $ config , $ language , 'install' ) ) ) ; $ matrix -> setDimension ( 'before_script' , array ( $ this -> getConfigValue ( $ config , $ language , 'before_script' ) ) ) ; $ matrix -> setDimension ( 'script' , array ( $ this -> getConfigValue ( $ config , $ language , 'script' ) ) ) ; return $ matrix ; }
Create matrix of build

@param array $config

@return Matrix
Create matrix of build