PHP code example of alytvynov / loaders

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

    

alytvynov / loaders example snippets


use Common\Traits\DataLoader;
use Common\Traits\RawLoader;

class Product
{
    use DataLoader;
    use RawLoader;
   
    /**
     * @var string
     */
    protected string $title;
   
    /**
     * @return string
     */
    public function getTitle(): string
    {
        return $this->title;
    }
   
    /**
     * @param string $title
     *
     * @return $this                     
     */
    public function setTitle(string $title): self
    {
        $this->title = $title;
        
        return $this;
    }
}
   

$data = [
    'title' => 'This is product',
];
   
$product = new Product();
$product->loadData($data);

$product->toArray($data);