for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* CRM library
* @author Tao <[email protected]>
*/
namespace Slince\Crm;
use Slince\Crm\Exception\InvalidArgumentException;
class Registry
{
* Registry name
* @var string
protected $name;
* Registry url
protected $url;
* Registry homepage
protected $homepage;
* Registry author
protected $author;
public function __construct($name, $url, $homepage = null, $author = null)
$this->name = $name;
$this->url = $url;
$this->homepage = $homepage;
$this->author = $author;
}
* @param string $name
public function setName($name)
* @param string $url
public function setUrl($url)
* @param string $homepage
public function setHomepage($homepage)
* @param string $author
public function setAuthor($author)
* @return string
public function getName()
return $this->name;
public function getUrl()
return $this->url;
public function getHomepage()
return $this->homepage;
public function getAuthor()
return $this->author;
* convert to array
* @return array
public function toArray()
return [
'name' => $this->name,
'url' => $this->url,
'homepage' => $this->homepage,
'author' => $this->author,
];
* factory method
* @param $registryData
* @throws InvalidArgumentException
* @return static
public static function create($registryData)
if (empty($registryData['name']) || empty($registryData['url'])) {
throw new InvalidArgumentException("Registry data must contain key [name] and [url]");
$homepage = isset($registryData['homepage']) ? $registryData['homepage'] : '';
$author = isset($registryData['author']) ? $registryData['author'] : '';
return new static($registryData['name'], $registryData['url'], $homepage, $author);