Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. class TimeSlot {
  4.   private $posts = [];
  5.  
  6.   public function isAvailable();
  7.   public function publish(Post $post) {
  8.     $this->posts[] = $post;
  9.     $post->onPublish($this);
  10.   }
  11. }
  12.  
  13. class Post {
  14.   private $publicationSlots = [];
  15.   public function onPublish(TimeSlot $timeSlot) {
  16.     $this->publicationSlots[] = $timeSlot;
  17.   }
  18.  
  19.   public function canBePublished() {
  20.     return count($this->publicationSlots) < 3;
  21.   }
  22. }
  23.  
  24.  
  25. $timeSlot = $repo->findForDate($dateTime);
  26. $timeSlot->publish($post);
  27. $repo->save($timeSlot);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement