PHP Classes

File: src/bootstrap.php

Recommend this page to a friend!
  Classes of Axel Pardemann   PHP UUID Extension Functions   src/bootstrap.php   Download  
File: src/bootstrap.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP UUID Extension Functions
Extend a string type to return a unique identifier
Author: By
Last change:
Date: 5 years ago
Size: 1,020 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
NorseBlue\StringExtensions\UUID;

use
NorseBlue\ScalarObjects\Types\StringType;
use
Symfony\Component\Finder\Finder;
use function
NorseBlue\ScalarObjects\path_merge;

/**
 * @codeCoverageIgnore
 */
(static function (): void {
   
$extensions_path = path_merge(__DIR__, 'Extensions');
   
$extensions = array_keys(
       
iterator_to_array(
           
Finder::create()
                ->
in($extensions_path)
                ->
name("String*Extension.php")
                ->
files()
        )
    );

    foreach (
$extensions as $path) {
       
$pattern = '%^' . path_merge($extensions_path, 'String') . '(.+)Extension\.php$%';
       
$name = preg_replace($pattern, '\1', $path);

       
$extension = path_merge(
           
'NorseBlue\StringExtensions\UUID',
            [
               
'Extensions',
               
"String{$name}Extension",
            ],
           
'\\'
       
);

       
StringType::registerExtensionMethod(lcfirst($name), $extension);
    }
})();