Skip to content

tamiroh/php-dataclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Dataclass

Basic Usage

<?php

class Human extends Data
{
    public int $age;
    public int $weight;
    public int $height;
    public string $name;
    public ?string $address;

    public function greeting(): string
    {
        return "Hello, my name is {$this->name}!";
    }
}

$human = new Human([
    'age' => 22,
    'weight' => 51,
    'height' => 172,
    'name' => 'John',
    'address' => '1600 Pennsylvania Avenue NW Washington, D.C. 20500 U.S.'
]);

About

Data class for PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages