1. Go to this page and download the library: Download nabeghe/traituctor 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/ */
nabeghe / traituctor example snippets
use Nabeghe\Traituctor\Traituctor;
trait A
{
protected $numberA;
public function __constructA($baseNumber)
{
echo "A\n";
$this->numberA = $baseNumber + 3;
}
}
trait B
{
protected $numberB;
public function __constructB($baseNumber)
{
echo "B\n";
$this->numberB = $baseNumber + 4;
}
}
class Main
{
use A, B;
public function __construct($baseNumber)
{
echo "Main\n";
Traituctor::construct($this, [$baseNumber]);
}
public function multiply()
{
return $this->numberA * $this->numberB;
}
}
echo (new Main(10))->multiply();
// Main
// A
// B
// 182
use Nabeghe\Traituctor\Traituctor;
use Nabeghe\Traituctor\Requirements;
#[Requirements(B::class)]
trait A
{
protected $numberA;
public function __constructA($baseNumber)
{
echo "A\n";
$this->numberA = $this->numberB + 1;
}
}
trait B
{
protected $numberB;
public function __constructB($baseNumber)
{
echo "B\n";
$this->numberB = $baseNumber + 3;
}
}
class Main
{
use A, B;
public function __construct($baseNumber)
{
echo "Main\n";
Traituctor::construct($this, [$baseNumber], true);
}
public function multiply()
{
return $this->numberA * $this->numberB;
}
}
echo (new Main(10))->multiply();
// Main
// B
// A
// 182
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.