src/Classifier.php
public function classify(ReflectionClass $class)
    {
        $mergedClassifiers = array_merge(
            self::DEFAULT_CLASSIFIER,
            config('stats.custom_component_classifier', [])
        );

        foreach ($mergedClassifiers as $classifier) {
            $c = new $classifier();

            if (! $this->implementsContract($classifier)) {
                throw new Exception("Classifier {$classifier} does not implement ".ClassifierContract::class.'.');
            }

            try {
                $satisfied = $c->satisfies($class);
            } catch (Exception $e) {
                $satisfied = false;
            }

            if ($satisfied) {
                return $c->getName();
            }
        }

        return 'Other';
    }
public function classify(ReflectionClass $class)
    {
        $mergedClassifiers = array_merge(
            self::DEFAULT_CLASSIFIER,
            config('stats.custom_component_classifier', [])
        );

        foreach ($mergedClassifiers as $classifier) {
            $c = new $classifier();

            if (! $this->implementsContract($classifier)) {
                throw new Exception("Classifier {$classifier} does not implement ".ClassifierContract::class.'.');
            }

            try {
                $satisfied = $c->satisfies($class);
            } catch (Exception $e) {
                $satisfied = false;
            }

            if ($satisfied) {
                return $c->getName();
            }
        }

        return 'Other';
    }
public function classify ( ReflectionClass $ class ) { $ mergedClassifiers = array_merge ( self :: DEFAULT_CLASSIFIER , config ( 'stats.custom_component_classifier' , [ ] ) ) ; foreach ( $ mergedClassifiers as $ classifier ) { $ c = new $ classifier ( ) ; if ( ! $ this -> implementsContract ( $ classifier ) ) { throw new Exception ( "Classifier {$classifier} does not implement " . ClassifierContract :: class . '.' ) ; } try { $ satisfied = $ c -> satisfies ( $ class ) ; } catch ( Exception $ e ) { $ satisfied = false ; } if ( $ satisfied ) { return $ c -> getName ( ) ; } } return 'Other' ; }
Classify a given Class by an available Classifier Strategy.

@param ReflectionClass $class
@return string
Classify a given Class by an available Classifier Strategy .