I have tough time making this design decision.
I could go with traditional new
language construct to initialize objects, and use them through variables, such as:
$o = new Object('arg');
$o->method();
$o->property = 'value';
$o->save();
Or I can choose factory pattern and aggressive chainability like as
Object::new('arg')->method()->setProperty('value')->save();
which would result in
- less LOC to
- read,
- maintain,
- refactor,
- no need to name variables.
However, I'm not sure if this is an acceptable approach, and if I forgot to take something into account.
Please express your worries or agreement, and guidance as how I could make my decision.