PHP code example of alkaupp / readonly

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

    

alkaupp / readonly example snippets



declare(strict_types=1);

namespace Tests\Alkaupp\Readonly;

use Alkaupp\Readonly\Readonly;
use DateTime;

/**
 * @property string $firstName
 * @property string $lastName
 * @property DateTime $birthday
 */
final class Example
{
    use Readonly;

    private $firstName;
    private $lastName;
    private $birthday;

    public function __construct(string $firstName, string $lastName, DateTime $birthday)
    {
        $this->firstName = $firstName;
        $this->lastName = $lastName;
        $this->birthday = $birthday;
    }
}