PHP code example of liuggio / filler-dto

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

    

liuggio / filler-dto example snippets

 php
class Cart
{
    private $a;
    private $b;
    private $c;

    private function __construct($a, $b, $c)
    {
        $this->a = $a;
        $this->b = $b;
        $this->c = $c;
    }

    public static function startShipping(StartShippingData $data)
    {
        return new self($data->a, $data->b, null);
    }

    public static function addProduct(AddProductData $data)
    {
        return new self(null, $data->b, $data->cs);
    }
}
 php
class Cart
{
    use PropertyTrait;

    private $a;
    private $b;
    private $c;

    private function __construct($dto)
    {
        $this->fillProperties($dto);
    }

    public static function startShipping(StartShippingData $data)
    {
        return new self($data);
    }

    public static function addProduct(AddProductData $data)
    {
        return new self($data);
    }
}

class StartShippingData
{
    public $a;
    public $b;
}

class AddProductData
{
    public $b;
    public $c;
}
 php
use Liuggio\Filler\HTTPPropertyTrait;

class StartShippingDTO
{
    use HTTPPropertyTrait;

    private $developer;

    public function __construct(Request $request)
    {
        $this->fillPropertiesFromRequest($request);
    }
...
}

Class Controller
{
    public function startShippingAction(Request $request)
    {
        $startShipping = new StartShippingDTO($request);

        if ($this->isValid($startShipping)) ...
    }
}