Skip to content

Instantly share code, notes, and snippets.

@ericlbarnes
Created January 22, 2014 16:22
Show Gist options
  • Save ericlbarnes/8561773 to your computer and use it in GitHub Desktop.
Save ericlbarnes/8561773 to your computer and use it in GitHub Desktop.
Which one is better?
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);
}
@ericlbarnes
Copy link
Author

@brayniverse If you are coding to the interface then it would need this. Otherwise you can't guarantee createFromArray would exist.

@brayniverse
Copy link

@ericbarnes Makes sense.

@JonoB
Copy link

JonoB commented Jan 22, 2014

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