Skip to content

Commit

Permalink
Combine these if statements into one to reduce the cyclomatic complex…
Browse files Browse the repository at this point in the history
…ity.
  • Loading branch information
jgen committed Apr 26, 2014
1 parent efb5038 commit a8dd045
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
36 changes: 13 additions & 23 deletions ext/notes/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,26 +323,16 @@ private function update_note()
$noteText = mysql_real_escape_string(html_escape($_POST["note_text"]));

// validate parameters
if(is_null($imageID) || !is_numeric($imageID))
return;

if(is_null($noteID) || !is_numeric($noteID))
return;

if(is_null($noteX1) || !is_numeric($noteX1))
return;

if(is_null($noteY1) || !is_numeric($noteY1))
return;

if(is_null($noteHeight) || !is_numeric($noteHeight))
return;

if(is_null($noteWidth) || !is_numeric($noteWidth))
return;

if(is_null($noteText) || strlen($noteText) == 0)
if (is_null($imageID) || !is_numeric($imageID) ||
is_null($noteID) || !is_numeric($noteID) ||
is_null($noteX1) || !is_numeric($noteX1) ||
is_null($noteY1) || !is_numeric($noteY1) ||
is_null($noteHeight) || !is_numeric($noteHeight) ||
is_null($noteWidth) || !is_numeric($noteWidth) ||
is_null($noteText) || strlen($noteText) == 0)
{
return;
}

global $database;
$database->execute("UPDATE notes ".
Expand All @@ -369,11 +359,11 @@ private function delete_note()
$noteID = int_escape($_POST["note_id"]);

// validate parameters
if(is_null($imageID) || !is_numeric($imageID))
return;

if(is_null($noteID) || !is_numeric($noteID))
if( is_null($imageID) || !is_numeric($imageID) ||
is_null($noteID) || !is_numeric($noteID))
{
return;
}

global $database;

Expand Down
2 changes: 1 addition & 1 deletion ext/notes/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,5 @@ public function display_history($histories, $pageNumber, $totalPages) {

$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
}
}
}

0 comments on commit a8dd045

Please sign in to comment.