SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top