Skip to content

Commit

Permalink
Merge two if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaszak committed Mar 23, 2016
1 parent 45199d2 commit 101a60a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/Scope/FileRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
*
* @copyright 2015 Tomasz Ignaszak
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
declare(strict_types=1);

namespace Ignaszak\Registry\Scope;

use Ignaszak\Registry\Conf;
use Ignaszak\Registry\RegistryException;

/**
*
Expand All @@ -23,9 +23,9 @@ class FileRegistry extends IRegistry
{

/**
* @param string $name
* @param object $value
* @throws Exception
*
* {@inheritDoc}
* @see \Ignaszak\Registry\Scope\IRegistry::set($name, $value)
*/
public function set(string $name, $value)
{
Expand All @@ -34,14 +34,13 @@ public function set(string $name, $value)

parent::set($name, $this->get($name));

} else { // If not create new file

if (! is_dir(Conf::getTmpPath())) {
if (! @mkdir(Conf::getTmpPath(), 0777, true)) {
throw new \RuntimeException(
"Can't create '" . Conf::getTmpPath() . "' folder"
);
}
} 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())) {
Expand All @@ -51,7 +50,7 @@ public function set(string $name, $value)
serialize($value)
);
} else {
throw new \RuntimeException(
throw new RegistryException(
"Permission denied (" . Conf::getTmpPath() . ")"
);
}
Expand Down

0 comments on commit 101a60a

Please sign in to comment.