Whip_BasicMessage

Class Whip_Message.

Defined (1)

The class is defined in the following location(s).

/vendor/yoast/whip/src/messages/Whip_BasicMessage.php  
  1. class Whip_BasicMessage implements Whip_Message { 
  2. /** 
  3. * @var string 
  4. */ 
  5. private $body; 
  6.  
  7. /** 
  8. * Whip_Message constructor. 
  9. * @param string $body 
  10. * @throws Whip_EmptyProperty 
  11. * @throws Whip_InvalidType 
  12. */ 
  13. public function __construct($body) { 
  14. $this->validateParameters( $body ); 
  15.  
  16. $this->body = $body; 
  17.  
  18. /** 
  19. * @return string 
  20. */ 
  21. public function body() { 
  22. return $this->body; 
  23.  
  24. private function validateParameters( $body ) { 
  25. if ( empty( $body ) ) { 
  26. throw new Whip_EmptyProperty( 'Message body' ); 
  27.  
  28. if ( ! is_string( $body ) ) { 
  29. throw new Whip_InvalidType( 'Message body', "string", $body );