kola-er / potato-orm Goto Github PK
View Code? Open in Web Editor NEWORM package that manages the persistence of database CRUD operations.
License: MIT License
ORM package that manages the persistence of database CRUD operations.
License: MIT License
Your project should be connected with Travis and your README file should have the badge that exhibits the passing/failure
status
Your functions should be as atomic as possible
try {
$table = Backbone::mapClassToTable(get_called_class());
} catch (TableDoesNotExistException $e) {
return $e->message();
}
This block of code is called in almost all the functions in this class. You can make a method for it and just call the method itself in place of this chunk everywhere
This should be connected to travis and the badge for passing/failing should be included in the README
Read Laravel's source code to have an idea about testing all your ORM methods here
namespace Kola\PotatoOrm\Helper;
use Kola\PotatoOrm\Exception\UnsuccessfulDbConnException as ConnEx;
use \PDO;
Imports should be from shortest to longest. Rearrange
/**
* Override the parent class PDO constructor to prevent instantiation-argument requirement
*/
public function __construct()
{
}
Any reason why there is an empty constructor here?
public static function mapClassToTable($className)
{
$demarcation = strrpos($className, '\\', -1);
if ($demarcation !== false) {
$table = strtolower(substr($className, $demarcation + 1));
} else {
$table = strtolower($className);
}
if (! self::checkForTable($table)) {
$temp = ucfirst($table);
if (self::checkForTable($temp)) {
return $temp;
} else {
$arrayOfCharInTable = str_split($table);
if ($arrayOfCharInTable[count($arrayOfCharInTable) - 1] === 's') {
array_pop($arrayOfCharInTable);
$table = implode($arrayOfCharInTable);
} else {
$table .= 's';
}
if (! self::checkForTable($table)) {
$temp = ucfirst($table);
if (self::checkForTable($temp)) {
return $temp;
} else {
throw new TableDoesNotExistException;
}
}
}
}
return $table;
}
This function is doing too much.
$arrayOfCharInTable = str_split($table);
if ($arrayOfCharInTable[count($arrayOfCharInTable) - 1] === 's') {
array_pop($arrayOfCharInTable);
$table = implode($arrayOfCharInTable);
} else {
$table .= 's';
}
can be abstracted into another method and just called with the necessary arguments.
if (! self::checkForTable($table)) {
$temp = ucfirst($table);
if (self::checkForTable($temp)) {
return $temp;
} else {
throw new TableDoesNotExistException;
}
}
This is repeated, so you can have a method to accomodate it, then logically include it in the mapClassToTable()
methods.
Line 74 - it should be existence
not existent
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.