for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of sensorario/resources repository
*
* (c) Simone Gentili <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sensorario\Resources;
use RuntimeException;
use Sensorario\Resources\Validators\ResourcesValidator;
class Resource
extends MagicResource
implements Interfaces\ResourceInterface
{
protected static $allowed = [];
protected static $mandatory = [];
protected static $defaults = [];
public static function mandatory()
return static::$mandatory;
}
public static function allowed()
return static::$allowed;
public static function allowedValues()
return [];
public static function rules()
public static function defaults()
return static::$defaults;
public function applyConfiguration(
$resourceName,
Container $config
) {
static::$allowed = $config->allowed($resourceName);
static::$mandatory = $config->mandatory($resourceName);
static::$defaults = $config->defaults($resourceName);
public static function fromConfiguration(
Container $container,
$validationRequired = true
$resource = new self(
[],
new ResourcesValidator(),
$validationRequired
);
$resource->applyConfiguration(
$container
return $resource;