Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class TimeSlot {
- private $posts = [];
- public function isAvailable();
- public function publish(Post $post) {
- $this->posts[] = $post;
- $post->onPublish($this);
- }
- }
- class Post {
- private $publicationSlots = [];
- public function onPublish(TimeSlot $timeSlot) {
- $this->publicationSlots[] = $timeSlot;
- }
- public function canBePublished() {
- return count($this->publicationSlots) < 3;
- }
- }
- $timeSlot = $repo->findForDate($dateTime);
- $timeSlot->publish($post);
- $repo->save($timeSlot);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement