darya / framework

PHP Web Application Framework
http://darya.io/
MIT License
2 stars 1 forks source link

Extract model mutator/accessor logic to their own classes #23

Closed hexus closed 9 years ago

hexus commented 9 years ago

Model::mutate() and Model::access() are rated critical by scrutinizer because of the switch statements.

Extract this logic to a couple of new classes:

Darya\Database\Model\Mutator
Darya\Database\Model\Accessor

Maybe also add interfaces for these so that they can be overridden/extended.

hexus commented 9 years ago

Implemented as above. PHPUnit tests succeeded absolutely fine on the first attempt.

Successful extraction was successful. As a side effect, developers can also implement their own transformers for their own active record classes if they want. They just need to override Record::getAttributeAccessor() and Record::getAttributeMutator().