public function getDefaultEnvironmentId(array $environments)
    {
        // If there is only one environment, use that.
        if (count($environments) <= 1) {
            $environment = reset($environments);

            return $environment ? $environment->id : null;
        }

        // Check if there is only one "main" environment.
        $main = array_filter($environments, function (Environment $environment) {
            return $environment->is_main;
        });
        if (count($main) === 1) {
            $environment = reset($main);

            return $environment ? $environment->id : null;
        }

        // Check if there is a "master" environment.
        if (isset($environments['master'])) {
            return 'master';
        }

        return null;
    }
public function getDefaultEnvironmentId(array $environments)
    {
        // If there is only one environment, use that.
        if (count($environments) <= 1) {
            $environment = reset($environments);

            return $environment ? $environment->id : null;
        }

        // Check if there is only one "main" environment.
        $main = array_filter($environments, function (Environment $environment) {
            return $environment->is_main;
        });
        if (count($main) === 1) {
            $environment = reset($main);

            return $environment ? $environment->id : null;
        }

        // Check if there is a "master" environment.
        if (isset($environments['master'])) {
            return 'master';
        }

        return null;
    }
public function getDefaultEnvironmentId ( array $ environments ) { // If there is only one environment, use that. if ( count ( $ environments ) <= 1 ) { $ environment = reset ( $ environments ) ; return $ environment ? $ environment -> id : null ; } // Check if there is only one "main" environment. $ main = array_filter ( $ environments , function ( Environment $ environment ) { return $ environment -> is_main ; } ) ; if ( count ( $ main ) === 1 ) { $ environment = reset ( $ main ) ; return $ environment ? $ environment -> id : null ; } // Check if there is a "master" environment. if ( isset ( $ environments [ 'master' ] ) ) { return 'master' ; } return null ; }
Get the default environment in a list.

@param array $environments An array of environments, keyed by ID.

@return string|null
Get the default environment in a list .