protected function loadComponents($paths)
    {
        $paths = array_unique(is_array($paths) ? $paths : (array) $paths);

        $paths = array_filter($paths, function ($path) {
            return is_dir($path);
        });

        if (empty($paths)) {
            return;
        }

        $namespace = $this->app->getNamespace();

        foreach ((new Finder())->in($paths)->exclude('Observers')->files() as $file) {
            $class = trim($namespace, '\\') . '\\'
                . str_replace(
                    ['/', '.php'],
                    ['\\', ''],
                    Str::after(
                        realpath($file->getPathname()),
                        app_path() . DIRECTORY_SEPARATOR
                    )
                );

            if (is_subclass_of($class, Component::class)
                && ! (new \ReflectionClass($class))->isAbstract()
            ) {
                $this->registerComponent($class);
            }
        }
    }
protected function loadComponents($paths)
    {
        $paths = array_unique(is_array($paths) ? $paths : (array) $paths);

        $paths = array_filter($paths, function ($path) {
            return is_dir($path);
        });

        if (empty($paths)) {
            return;
        }

        $namespace = $this->app->getNamespace();

        foreach ((new Finder())->in($paths)->exclude('Observers')->files() as $file) {
            $class = trim($namespace, '\\') . '\\'
                . str_replace(
                    ['/', '.php'],
                    ['\\', ''],
                    Str::after(
                        realpath($file->getPathname()),
                        app_path() . DIRECTORY_SEPARATOR
                    )
                );

            if (is_subclass_of($class, Component::class)
                && ! (new \ReflectionClass($class))->isAbstract()
            ) {
                $this->registerComponent($class);
            }
        }
    }
protected function loadComponents ( $ paths ) { $ paths = array_unique ( is_array ( $ paths ) ? $ paths : ( array ) $ paths ) ; $ paths = array_filter ( $ paths , function ( $ path ) { return is_dir ( $ path ) ; } ) ; if ( empty ( $ paths ) ) { return ; } $ namespace = $ this -> app -> getNamespace ( ) ; foreach ( ( new Finder ( ) ) -> in ( $ paths ) -> exclude ( 'Observers' ) -> files ( ) as $ file ) { $ class = trim ( $ namespace , '\\' ) . '\\' . str_replace ( [ '/' , '.php' ] , [ '\\' , '' ] , Str :: after ( realpath ( $ file -> getPathname ( ) ) , app_path ( ) . DIRECTORY_SEPARATOR ) ) ; if ( is_subclass_of ( $ class , Component :: class ) && ! ( new \ ReflectionClass ( $ class ) ) -> isAbstract ( ) ) { $ this -> registerComponent ( $ class ) ; } } }
Load component class from the paths

@param mixed $paths
@throws \ReflectionException
Load component class from the paths