PHP SOLID, Repository Pattern ve Clean Architecture
SOLID
- S — Single Responsibility
- O — Open/Closed
- L — Liskov Substitution
- I — Interface Segregation
[*]D — Dependency Inversion
Repository Pattern
interface PostRepositoryInterface {
public function find(int $id): ?Post;
public function all(): Collection;
public function save(Post $post): void;
}
class EloquentPostRepository implements PostRepositoryInterface {
public function find(int $id): ?Post { return Post::find($id); }
public function all(): Collection { return Post::all(); }
public function save(Post $post): void { $post->save(); }
}
Kategori:
PHP
Bu konuyu EL11.Net forumunda tartışmak ister misiniz?
Forumda Gör