PHP code example of ajf / newtype

1. Go to this page and download the library: Download ajf/newtype library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ajf / newtype example snippets




namespace JaneBlogges\WonderfulApp;

use function ajf\newType\newType;

// Makes the new opaque type!
newType(FilePath::class, 'string');

function moveFile(FilePath $sourcePath, FilePath $destinationPath): bool {
    return rename($sourcePath->unbox(), $destinationPath->unbox());
}

moveFile(new FilePath('foo'), new FilePath('bar'));