Skip to content

Commit

Permalink
Code style optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
thelfensdrfer committed Jan 7, 2021
1 parent faea068 commit 23fba9a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/AutoUpdate.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php namespace VisualAppeal;
<?php

use Composer\Semver\Comparator;
namespace VisualAppeal;

use Exception;
use RuntimeException;

use Composer\Semver\Comparator;
use Desarrolla2\Cache\CacheInterface;
use Desarrolla2\Cache\NotCache;

use Exception;
use Monolog\Handler\HandlerInterface;
use Monolog\Logger;
use Monolog\Handler\NullHandler;

use Psr\SimpleCache\InvalidArgumentException;
use VisualAppeal\Exceptions\DownloadException;
use VisualAppeal\Exceptions\ParserException;
Expand Down Expand Up @@ -225,7 +226,7 @@ public function setTempDir(string $dir): bool
if (!is_dir($dir)) {
$this->log->debug(sprintf('Creating new temporary directory "%s"', $dir));

if (!mkdir($dir, 0755, true)) {
if (!mkdir($dir, 0755, true) && !is_dir($dir)) {
$this->log->critical(sprintf('Could not create temporary directory "%s"', $dir));

return false;
Expand All @@ -250,7 +251,7 @@ public function setInstallDir(string $dir): bool
if (!is_dir($dir)) {
$this->log->debug(sprintf('Creating new install directory "%s"', $dir));

if (!mkdir($dir, 0755, true)) {
if (!mkdir($dir, 0755, true) && !is_dir($dir)) {
$this->log->critical(sprintf('Could not create install directory "%s"', $dir));

return false;
Expand Down Expand Up @@ -697,7 +698,9 @@ protected function simulateInstall(string $updateFile): bool

// Check if parent directory is writable
if (!is_dir($foldername)) {
mkdir($foldername);
if (!mkdir($foldername) && !is_dir($foldername)) {
throw new RuntimeException( sprintf( 'Directory "%s" was not created', $foldername ) );
}
$this->log->debug(sprintf('[SIMULATE] Create directory "%s"', $foldername));
$files[$i]['parent_folder_exists'] = false;

Expand Down Expand Up @@ -812,7 +815,7 @@ protected function install(string $updateFile, bool $simulateInstall, string $ve
$this->log->debug(sprintf('Updating file "%s"', $filename));

if (!is_dir($foldername)) {
if (!mkdir($foldername, $this->dirPermissions, true)) {
if (!mkdir($foldername, $this->dirPermissions, true) && !is_dir($foldername)) {
$this->log->error(sprintf('Directory "%s" has to be writeable!', $foldername));

return false;
Expand Down

0 comments on commit 23fba9a

Please sign in to comment.