PHP code example of dunice / dto

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

    

dunice / dto example snippets



$params = array(
    'idPerson' => 1,
    'idAddress' => array(
        'idAddress' => 1,
        'txAddress' => '5th Avenue, 1250'
    )
);
$dto = new \Dto\Mapping\Base($params);

$dto->getIdPerson(); // 1
$dto->getIdAddress(); // DtoObject
$dto->getIdAddress()->getIdAddress(); // 1
$dto->getIdAddress()->getTxAddress(); // 5th Avenue, 1250


$params = array(
  'idPerson' => 1
);
$dto = new \Dto\Mapping\Base($params);

$dto->getIdPerson(); // 1

// Now set an address info
$dto->setIdAddress(array(
    'idAddress' => 1,
    'txAddress' => '5th Avenue, 1250'
));

$dto->getIdAddress(); // DtoObject
$dto->getIdAddress()->getIdAddress(); // 1
$dto->getIdAddress()->getTxAddress(); // 5th Avenue, 1250