protected static function findOneByType($type)
    {
        // Look in the cache
        if (null !== ($class = self::getFromCache($type))) {
            return $class;
        }

        $exceptions = [];
        foreach (self::$strategies as $strategy) {
            try {
                $candidates = call_user_func($strategy.'::getCandidates', $type);
            } catch (StrategyUnavailableException $e) {
                $exceptions[] = $e;

                continue;
            }

            foreach ($candidates as $candidate) {
                if (isset($candidate['condition'])) {
                    if (!self::evaluateCondition($candidate['condition'])) {
                        continue;
                    }
                }

                // save the result for later use
                self::storeInCache($type, $candidate);

                return $candidate['class'];
            }

            $exceptions[] = new NoCandidateFoundException($strategy, $candidates);
        }

        throw DiscoveryFailedException::create($exceptions);
    }
protected static function findOneByType($type)
    {
        // Look in the cache
        if (null !== ($class = self::getFromCache($type))) {
            return $class;
        }

        $exceptions = [];
        foreach (self::$strategies as $strategy) {
            try {
                $candidates = call_user_func($strategy.'::getCandidates', $type);
            } catch (StrategyUnavailableException $e) {
                $exceptions[] = $e;

                continue;
            }

            foreach ($candidates as $candidate) {
                if (isset($candidate['condition'])) {
                    if (!self::evaluateCondition($candidate['condition'])) {
                        continue;
                    }
                }

                // save the result for later use
                self::storeInCache($type, $candidate);

                return $candidate['class'];
            }

            $exceptions[] = new NoCandidateFoundException($strategy, $candidates);
        }

        throw DiscoveryFailedException::create($exceptions);
    }
protected static function findOneByType ( $ type ) { // Look in the cache if ( null !== ( $ class = self :: getFromCache ( $ type ) ) ) { return $ class ; } $ exceptions = [ ] ; foreach ( self :: $ strategies as $ strategy ) { try { $ candidates = call_user_func ( $ strategy . '::getCandidates' , $ type ) ; } catch ( StrategyUnavailableException $ e ) { $ exceptions [ ] = $ e ; continue ; } foreach ( $ candidates as $ candidate ) { if ( isset ( $ candidate [ 'condition' ] ) ) { if ( ! self :: evaluateCondition ( $ candidate [ 'condition' ] ) ) { continue ; } } // save the result for later use self :: storeInCache ( $ type , $ candidate ) ; return $ candidate [ 'class' ] ; } $ exceptions [ ] = new NoCandidateFoundException ( $ strategy , $ candidates ) ; } throw DiscoveryFailedException :: create ( $ exceptions ) ; }
Finds a class.

@param string $type

@return string|\Closure

@throws DiscoveryFailedException
Finds a class .