MagicSpice is a class utility similar to Lombok. It provides simple definitions for common constructor/getters/setters. It also integrates well with many existing IDEs.
class Employee
{
use MagicSpice\ClassHelper, MagicSpice\ClassHelper\Accessor\Set {
getInt as public getId;
getString as public getFirstName;
getString as public getLastName;
getFloatOrNull as public getYearsOfService;
setFloatOrNull as public setYearsOfService;
}
}
$john = new Employee([
'id' => 100,
'first_name' => 'John',
'last_name' => 'Doe',
]);
print $john->getFirstName() . $john->getLastName();
$john->setYearsOfService(2.5);
print $john->getYearsOfService();