PHP code example of mbernet / dto-parser

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

    

mbernet / dto-parser example snippets


class SuccessDTO extends BaseDTO {
    public $message;
    public $id;

    /**
     * SuccessDTO constructor.
     *
     * @param $message
     * @param $id
     */
    public function __construct(string $message, $id = null)
    {
        $this->message = $message;
        $this->id = $id;
    }
}


$successObject = SuccessDTO::toDTO(['message' => 'success', 'id' => 23]); //Get instance of SuccessDTO class

$successes = SuccessDTO::toDTOArray([['message' => 'success', 'id' => 23],['message' => 'error', 'id' => null]]);