Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to separate responsibility of Cast from Entity. #1287

Closed
ytetsuro opened this issue Oct 3, 2018 · 2 comments
Closed

I want to separate responsibility of Cast from Entity. #1287

ytetsuro opened this issue Oct 3, 2018 · 2 comments

Comments

@ytetsuro
Copy link
Contributor

ytetsuro commented Oct 3, 2018

The current Entity class has the responsibility of Cast.
But, I would like to separate the responsibilities of Cast from Entity.
That is because Cast is highly likely to be used in various places and Entity and responsibility range are different.

The improvement approach is done in the following procedure.

  1. Create a Caster class.
  2. Implement casting of Entity class in Caster class.
  3. Make the Entity class depend on the Caster class.
  4. Delete cast process of Entity class.

Does CodeIgniter want such a PR?

https://github.com/bcit-ci/CodeIgniter4/blob/b840d0a6d307df4da956561b599e443e467195d6/system/Entity.php

@lonnieezell
Copy link
Member

Not sure this is needed. The response can already be served as either JSON or XML. This as a cast was only put in as a convenience to format it when it comes out of the database. And I allowed the PR on that because I've read json encoding is safer than PHP's serialize when it comes to storing stuff in the database.

Almost all of the conversions are simple things that PHP provides the ability do already.

@ytetsuro
Copy link
Contributor Author

ytetsuro commented Oct 3, 2018

I understand.

Thank you reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants