for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @package Laztopaz\potato-ORM
* @author Temitope Olotin <[email protected]>
* @license <https://opensource.org/license/MIT> MIT
*/
namespace Laztopaz\PotatoORM;
use Laztopaz\PotatoORM\TableNotCreatedException;
class DatabaseHelper {
public $dbConn;
* This is a constructor; a default method that will be called automatically during class instantiation
public function __construct($dbConnect)
{
$this->dbConn = $dbConnect;
}
* This method creates a particular table
* @param tableName
* $return boolean true or false
public function createTable($tableName, $conn = NULL)
if (is_null($conn)) {
$conn = $this->dbConn;
$sql = 'CREATE TABLE IF NOT EXISTS '.$tableName.'(';
$sql.= ' id INT( 11 ) AUTO_INCREMENT PRIMARY KEY, name VARCHAR( 100 ), gender VARCHAR( 10 ), alias VARCHAR( 150 ) NOT NULL, class VARCHAR( 150 ), stack VARCHAR( 50 ) )';
return $conn->exec($sql);
throw TableNotCreatedException::create("Check your database connection");
throw \Laztopaz\PotatoOR... database connection');
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.
return
die
exit
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.
return false
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.