/** * ResourceLimitVoter constructor. */ public function __construct(array $config = []) { $requiredConfig = ['supportedClass', 'limit', 'count']; $config = array_replace(['supportsResource' => Fn\always()], $config); foreach ($requiredConfig as $key) { if (!isset($config[$key])) { throw new \InvalidArgumentException("ResourceLimitVoter `{$key}` config missing."); } } $this->supportedClass = $config['supportedClass']; $this->_supportsResource = $config['supportsResource']; $this->_getLimit = $config['limit']; $this->_getCount = $config['count']; }
/** @test */ public function method_always() { $always = Fn\always(); $this->assertTrue($always()); $this->assertTrue($always(true)); $this->assertTrue($always(false)); }