Skip to content

Commit

Permalink
reduce cyclomatic complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
samayo committed Oct 22, 2017
1 parent 69506e7 commit 3135773
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/bulletproof.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function offsetUnset($offset)
*
* @param mixed $offset
*
* @return bool
* @return string|boolean
*/
public function offsetGet($offset)
{
Expand Down Expand Up @@ -236,7 +236,7 @@ public function getJson()
/**
* Returns the image mime type
*
* @return string
* @return null|string
*/
public function getMime()
{
Expand Down Expand Up @@ -280,7 +280,7 @@ protected function getImageMime($tmp_name)
/**
* Returns error string or false if no errors occurred
*
* @return string|bool
* @return string|false
*/
public function getError()
{
Expand All @@ -297,11 +297,7 @@ public function upload()
$image = $this;
$files = $this->_files;

if ($this->error) {
return false;
}

if (!isset($files['tmp_name'])) {
if ($this->error || !isset($files['tmp_name'])) {
return false;
}

Expand All @@ -327,7 +323,7 @@ public function upload()
if ($files['size'] < $minSize || $files['size'] > $maxSize) {
$min = intval($minSize / 1000) ?: 1;
$max = intval($maxSize / 1000) ?: 1;
$image->error = "Image size should be at least " . $min . " KB, and no more than " . $max . " KB";
$image->error = 'Image size should be at least ' . $min . ' KB, and no more than ' . $max . ' KB';
return null;
}

Expand Down Expand Up @@ -463,7 +459,7 @@ public function setLocation($dir = 'bulletproof', $permission = 0666)

/* check if we can create a file in the directory */
if (!is_writable($dir)) {
$this->error = "The images directory \"" . $dir . "\" is not writable!";
$this->error = 'The images directory \'' . $dir . '\' is not writable!';
return false;
}

Expand All @@ -483,4 +479,4 @@ public function moveUploadedFile($tmp_name, $destination)
{
return move_uploaded_file($tmp_name, $destination);
}
}
}

0 comments on commit 3135773

Please sign in to comment.