<?php

declare(strict_types=1);

namespace ProudNerds\Block;

final class BlockLoader
{

    /**
     * @return Block[]
     */
    public static function loadBlocks(string $path): array
    {
        $blocks = [];
        foreach (glob($path.'*.php') as $filename) {
            require_once $filename;
            $fn = explode(".",$filename);
            $filePath = $fn[0];
            $f = explode("/",$filePath);
            $class = end($f);
            $blocks[] = new $class();
        }
        return $blocks;

    }


}
