Last active
August 16, 2018 13:09
-
-
Save cn007b/a72e6e0089e1304507db2e1f181fc8e8 to your computer and use it in GitHub Desktop.
Value Object instead of Form - ValueObject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ValueObject | |
{ | |
protected $name; | |
public function __construct(array $args) | |
{ | |
if (!isset($args['name']) || $args['name'] === '') { | |
throw new InvalidArgumentException('name cannot be blank'); | |
} | |
$this->name = $args['name']; | |
} | |
public function getName() | |
{ | |
return $this->name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment