daily pastebin goal
89%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function randomString() {
  4.   return bin2hex(random_bytes(5));
  5. }
  6.  
  7. class Contact {
  8.   public $name = "";
  9.  
  10.   function __construct() {
  11.     $this->name = "Contact-".randomString();
  12.   }
  13. }
  14.  
  15. class ContactsFactory {
  16.   static function createContacts($count) {
  17.     $contacts = [];
  18.     for ($i = 0; $i < $count; $i++) {
  19.       $contact = new Contact();
  20.       $contacts[] = $contact;
  21.     }
  22.     return $contacts;
  23.   }
  24. }
  25.  
  26. $contacts = ContactsFactory::createContacts(3);
  27.  
  28. print_r($contacts);
  29.  
  30. ?>
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
 
Top