PHP code example of kkszymanowski / traitor

1. Go to this page and download the library: Download kkszymanowski/traitor 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/ */

    

kkszymanowski / traitor example snippets


use Traitor\Traitor;

Traitor::addTraits([
    FooTrait::class,
    BarTrait::class,
    BazTrait::class
])->toClass(FooClass::class);

//or

Traitor::addTrait(FooTrait::class)
       ->addTrait(BarTrait::class)
       ->addTrait(BazTrait::class)
       ->toClass(FooClass::class);

use Traitor\Traitor;

$alreadyUses = Traitor::alreadyUses(FooClass::class, BarTrait::class);

use Traitor\Handlers\AbstractTreeHandler;

$handler = new AbstractTreeHandler(file($originalFilePath), FooTrait::class, BarClass::class);

$newContent = $handler->handle()->toString();