нужно вернуть данные, как это:
Person::firstname('ali')->lastname('hamrani')->age('19');
мой код:
class Person {
protected $firstname;
protected $lastname;
protected $age;
public static function firstname($firstname)
{
$this->$firstname = $firstname;
}
public static function lastname($lastname)
{
$this->lastname = $lastname;
}
public static function age($age)
{
$this->age = $age;
}
public static function toArray()
{
return [
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'age' => $this->age
];
}
}
print_r(Person::firstname('ali')->lastname('hamrani')->age(19)->toArray());
мне нужно вернуть мне, как это:
[
'firstName' => 'ali',
'lastName' => 'hamrani',
'age' => 19,
]