Skip to content

Instantly share code, notes, and snippets.

@cn0047
Last active August 16, 2018 13:09
Show Gist options
  • Select an option

  • Save cn0047/a72e6e0089e1304507db2e1f181fc8e8 to your computer and use it in GitHub Desktop.

Select an option

Save cn0047/a72e6e0089e1304507db2e1f181fc8e8 to your computer and use it in GitHub Desktop.
Value Object instead of Form - ValueObject
<?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