for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DansMaCulotte\Monetico\Resources;
use DansMaCulotte\Monetico\Exceptions\Exception;
class Ressource
{
/** @var array */
protected $parameters = [];
protected $keys = [];
/**
* Ressource constructor.
* @param array $fields
* @throws Exception
*/
public function __construct(array $fields = [])
$this->setParameters($fields);
}
* @param string $name
* @return mixed
public function getParameter(string $name)
if (!in_array($name, $this->keys, true)) {
throw Exception::invalidResourceParameter($name);
if (isset($this->parameters[$name]) === false) {
return null;
return $this->parameters[$name];
* @param mixed $value
public function setParameter(string $name, $value = null): void
$this->parameters[$name] = $value;
public function setParameters(array $fields): void
foreach ($fields as $fieldKey => $fieldValue) {
$this->setParameter($fieldKey, $fieldValue);
* @return array
public function getParameters(): array
return $this->parameters;