Created
January 22, 2014 16:22
-
-
Save ericlbarnes/8561773 to your computer and use it in GitHub Desktop.
Which one is better?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface PostRepositoryInterface { | |
public function create($title, $content, $slug, array $meta, array $tags, $active, $user_id, Carbon $publish_date); | |
} | |
interface PostRepositoryInterface { | |
public function create(array $data); | |
} | |
@rtablada would you need the createFromArray in the interface? Shouldn't the interface only care about the creation method?
@brayniverse If you are coding to the interface then it would need this. Otherwise you can't guarantee createFromArray would exist.
@ericbarnes Makes sense.
interface PostRepositoryInterface {
public function create(array $data);
}
Any function taking more than 3-4 params is usually a code smell to me. At least until php gets named params.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about
Implementation:
This has the added benefit of throwing type errors when the final call to
create
is made. And allows for default params.