PHP code example of happyr / identifier-interface

1. Go to this page and download the library: Download happyr/identifier-interface library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

happyr / identifier-interface example snippets



class Message
{
  private $user;

  /* ... */

  public function setUser(IdentifierInterface $user)
  {
    $this->user = $user;
  }

  /* ... */
}

class MessageSenderService
{
  /* ... */
  public function send(Message $message, IdentifierInterface $recipient)
  {
     if ($message->getUser()->getId() == $recipient->getId()) {
        throw new \Exception("You can not send a message to yourself.");
     }

     /* ... */
  }
}


class User implements SymfonyUserInterface, AcmeMessageBundleIdInterface, OtherBundleInterface, AcmeDemoBundleUserInterface, CompanyBundleIdentifierInterface, MyIndentifierInterface
{
  /* ... */
}