/** * * {@inheritDoc} * @see \Ignaszak\Registry\Scope\IRegistry::set($name, $value) */ public function set(string $name, $value) : IRegistry { // Check if file is exists if (is_object($this->get($name))) { parent::set($name, $this->get($name)); } else { // If not create new file if (!is_dir(Conf::getTmpPath()) && !@mkdir(Conf::getTmpPath(), 0777, true)) { throw new RegistryException("Can't create '" . Conf::getTmpPath() . "' folder"); } if (is_writable(Conf::getTmpPath())) { parent::set($name, $value); file_put_contents(Conf::getTmpPath() . "/IgnaszakRegistry_{$name}.tmp", serialize($value)); } else { throw new RegistryException("Permission denied (" . Conf::getTmpPath() . ")"); } } return $this; }
public function testHas() { $this->assertFalse($this->IRegistry->has('test')); $this->IRegistry->set('test', 'string'); $this->assertTrue($this->IRegistry->has('test')); }