@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | trait Inflector |
40 | 40 | { |
41 | 41 | /** |
42 | - * Pluralizes English nouns. |
|
43 | - * |
|
44 | - * @access public |
|
45 | - * @static |
|
46 | - * @param string $word English noun to pluralize |
|
47 | - * @return string Plural noun |
|
48 | - */ |
|
42 | + * Pluralizes English nouns. |
|
43 | + * |
|
44 | + * @access public |
|
45 | + * @static |
|
46 | + * @param string $word English noun to pluralize |
|
47 | + * @return string Plural noun |
|
48 | + */ |
|
49 | 49 | public static function pluralize($word) |
50 | 50 | { |
51 | 51 | $plural = array( |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | - * Singularizes English nouns. |
|
106 | - * |
|
107 | - * @access public |
|
108 | - * @static |
|
109 | - * @param string $word English noun to singularize |
|
110 | - * @return string Singular noun. |
|
111 | - */ |
|
105 | + * Singularizes English nouns. |
|
106 | + * |
|
107 | + * @access public |
|
108 | + * @static |
|
109 | + * @param string $word English noun to singularize |
|
110 | + * @return string Singular noun. |
|
111 | + */ |
|
112 | 112 | public function singularize($word) |
113 | 113 | { |
114 | 114 | $singular = array ( |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | |
82 | 82 | $lowercased_word = strtolower($word); |
83 | 83 | |
84 | - foreach ($uncountable as $_uncountable){ |
|
85 | - if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){ |
|
84 | + foreach ($uncountable as $_uncountable) { |
|
85 | + if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) { |
|
86 | 86 | return $word; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - foreach ($irregular as $_plural=> $_singular){ |
|
90 | + foreach ($irregular as $_plural=> $_singular) { |
|
91 | 91 | if (preg_match('/('.$_plural.')$/i', $word, $arr)) { |
92 | - return preg_replace('/('.$_plural.')$/i', substr($arr[0],0,1).substr($_singular,1), $word); |
|
92 | + return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function singularize($word) |
113 | 113 | { |
114 | - $singular = array ( |
|
114 | + $singular = array( |
|
115 | 115 | '/(quiz)zes$/i' => "$1", |
116 | 116 | '/(matr)ices$/i' => "$1ix", |
117 | 117 | '/(vert|ind)ices$/i' => "$1ex", |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | 'move' => 'moves'); |
153 | 153 | |
154 | 154 | $lowercased_word = strtolower($word); |
155 | - foreach ($uncountable as $_uncountable){ |
|
156 | - if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){ |
|
155 | + foreach ($uncountable as $_uncountable) { |
|
156 | + if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) { |
|
157 | 157 | return $word; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - foreach ($irregular as $_plural=> $_singular){ |
|
161 | + foreach ($irregular as $_plural=> $_singular) { |
|
162 | 162 | if (preg_match('/('.$_singular.')$/i', $word, $arr)) { |
163 | - return preg_replace('/('.$_singular.')$/i', substr($arr[0],0,1).substr($_plural,1), $word); |
|
163 | + return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PotatoORM manages the persistence of database CRUD operations. |
|
4 | - * |
|
5 | - * @package Ibonly\PotatoORM\Model |
|
6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | - */ |
|
3 | + * PotatoORM manages the persistence of database CRUD operations. |
|
4 | + * |
|
5 | + * @package Ibonly\PotatoORM\Model |
|
6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | namespace Ibonly\PotatoORM; |
11 | 11 |
@@ -51,6 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * getTableName() |
53 | 53 | * |
54 | + * @param string $connection |
|
54 | 55 | * @return string |
55 | 56 | */ |
56 | 57 | public static function getTableName($connection) |
@@ -62,7 +63,7 @@ discard block |
||
62 | 63 | * getALL() |
63 | 64 | * Get all record from the database |
64 | 65 | * |
65 | - * @return object |
|
66 | + * @return GetData |
|
66 | 67 | */ |
67 | 68 | public function getALL($dbConnection = NULL) |
68 | 69 | { |
@@ -82,7 +83,7 @@ discard block |
||
82 | 83 | * where($data, $condition) |
83 | 84 | * Get data from database where $data = $condition |
84 | 85 | * |
85 | - * @return object |
|
86 | + * @return GetData |
|
86 | 87 | */ |
87 | 88 | public function where($data, $condition = NULL, $dbConnection = NULL) |
88 | 89 | { |
@@ -103,7 +104,7 @@ discard block |
||
103 | 104 | * find($value) |
104 | 105 | * Find data from database where id = $value |
105 | 106 | * |
106 | - * @return array |
|
107 | + * @return Model |
|
107 | 108 | */ |
108 | 109 | public static function find($value, $dbConnection = NULL) |
109 | 110 | { |
@@ -126,7 +127,7 @@ discard block |
||
126 | 127 | * save() |
127 | 128 | * Insert data into database |
128 | 129 | * |
129 | - * @return bool |
|
130 | + * @return string |
|
130 | 131 | */ |
131 | 132 | public function save($dbConnection = NULL) |
132 | 133 | { |
@@ -9,17 +9,12 @@ |
||
9 | 9 | |
10 | 10 | namespace Ibonly\PotatoORM; |
11 | 11 | |
12 | -use PDO; |
|
13 | -use Exception; |
|
14 | -use PDOException; |
|
15 | 12 | use Ibonly\PotatoORM\GetData; |
16 | 13 | use Ibonly\PotatoORM\DatabaseQuery; |
17 | 14 | use Ibonly\PotatoORM\ModelInterface; |
18 | 15 | use Ibonly\PotatoORM\UserNotFoundException; |
19 | 16 | use Ibonly\PotatoORM\EmptyDatabaseException; |
20 | 17 | use Ibonly\PotatoORM\SaveUserExistException; |
21 | -use Ibonly\PotatoORM\ColumnNotExistExeption; |
|
22 | -use Ibonly\PotatoORM\InvalidConnectionException; |
|
23 | 18 | |
24 | 19 | class Model extends DatabaseQuery implements ModelInterface |
25 | 20 | { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $sqlQuery = DatabaseQuery::selectAllQuery(self::getTableName($connection)); |
72 | 72 | $query = $connection->prepare($sqlQuery); |
73 | 73 | $query->execute(); |
74 | - if ( $query->rowCount() ) |
|
74 | + if ($query->rowCount()) |
|
75 | 75 | { |
76 | 76 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
77 | 77 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $sqlQuery = $databaseQuery->selectQuery(self::getTableName($connection), $data, $condition, $connection); |
93 | 93 | $query = $connection->prepare($sqlQuery); |
94 | 94 | $query->execute(); |
95 | - if ( $query->rowCount() ) |
|
95 | + if ($query->rowCount()) |
|
96 | 96 | { |
97 | 97 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
98 | 98 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $sqlQuery = DatabaseQuery::selectQuery(self::getTableName($connection), ['id' => $value], NULL, $connection); |
113 | 113 | $query = $connection->prepare($sqlQuery); |
114 | 114 | $query->execute(); |
115 | - if ( $query->rowCount() ) |
|
115 | + if ($query->rowCount()) |
|
116 | 116 | { |
117 | 117 | $found = new static; |
118 | 118 | $found->id = $value; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | $updateQuery = $this->updateQuery(self::getTableName($connection)); |
157 | 157 | $statement = $connection->prepare($updateQuery); |
158 | - if( $statement->execute() ) |
|
158 | + if ($statement->execute()) |
|
159 | 159 | { |
160 | 160 | return true; |
161 | 161 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | { |
173 | 173 | $connection = DatabaseQuery::checkConnection($dbConnection); |
174 | 174 | |
175 | - $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = '.$value); |
|
175 | + $query = $connection->prepare('DELETE FROM '.self::getTableName($connection).' WHERE id = '.$value); |
|
176 | 176 | $query->execute(); |
177 | 177 | $check = $query->rowCount(); |
178 | 178 | if ($check) |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * SugarORM\Schema manages the creation of database table. |
|
4 | - * |
|
5 | - * @package Ibonly\SugarORM\Schema |
|
6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | - */ |
|
3 | + * SugarORM\Schema manages the creation of database table. |
|
4 | + * |
|
5 | + * @package Ibonly\SugarORM\Schema |
|
6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | namespace Ibonly\PotatoORM; |
11 | 11 | |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | public function field($type, $fieldName, $length=NULL) |
29 | 29 | { |
30 | 30 | if(is_null($length)){ |
31 | - $this->fieldDescription[] = $type ." ".$fieldName; |
|
31 | + $this->fieldDescription[] = $type ." ".$fieldName; |
|
32 | 32 | }else |
33 | 33 | { |
34 | - $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
34 | + $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return array |
27 | 27 | */ |
28 | - public function field($type, $fieldName, $length=NULL) |
|
28 | + public function field($type, $fieldName, $length = NULL) |
|
29 | 29 | { |
30 | - if(is_null($length)){ |
|
31 | - $this->fieldDescription[] = $type ." ".$fieldName; |
|
32 | - }else |
|
30 | + if (is_null($length)) { |
|
31 | + $this->fieldDescription[] = $type." ".$fieldName; |
|
32 | + } else |
|
33 | 33 | { |
34 | - $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
34 | + $this->fieldDescription[] = $type." ".$fieldName." ".$length; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | $callback = function($fieldName) use (&$query) |
50 | 50 | { |
51 | 51 | $e = explode(" ", $fieldName); |
52 | - if(sizeof($e) == 2) |
|
52 | + if (sizeof($e) == 2) |
|
53 | 53 | { |
54 | - $query .= $this->$e[0]($e[1], 20) .", ".PHP_EOL; |
|
55 | - }else |
|
54 | + $query .= $this->$e[0]($e[1], 20).", ".PHP_EOL; |
|
55 | + } else |
|
56 | 56 | { |
57 | - $query .= $this->$e[0]($e[1], $e[2]) .", ".PHP_EOL; |
|
57 | + $query .= $this->$e[0]($e[1], $e[2]).", ".PHP_EOL; |
|
58 | 58 | } |
59 | 59 | }; |
60 | 60 | array_walk($this->fieldDescription, $callback); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function createTable($tablename, $connection = NULL) |
84 | 84 | { |
85 | - if(is_null($connection)) |
|
85 | + if (is_null($connection)) |
|
86 | 86 | { |
87 | 87 | $connection = DatabaseQuery::connect(); |
88 | 88 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | { |
91 | 91 | $sqlQuery = self::sanitizeQuery($tablename); |
92 | 92 | $query = $connection->prepare($sqlQuery); |
93 | - if($query->execute()) |
|
93 | + if ($query->execute()) |
|
94 | 94 | { |
95 | 95 | return true; |
96 | 96 | } |
97 | - }catch(PDOException $e){ |
|
97 | + } catch (PDOException $e) { |
|
98 | 98 | return $e->getMessage(); |
99 | 99 | } |
100 | 100 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function strings($value, $length) |
118 | 118 | { |
119 | - return $value ." varchar (".$length.") NOT NULL"; |
|
119 | + return $value." varchar (".$length.") NOT NULL"; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -201,6 +201,6 @@ discard block |
||
201 | 201 | $apend = 'timestamp'; |
202 | 202 | break; |
203 | 203 | } |
204 | - return $value . " " . $apend . " NOT NULL"; |
|
204 | + return $value." ".$apend." NOT NULL"; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | if(is_null($length)){ |
31 | 31 | $this->fieldDescription[] = $type ." ".$fieldName; |
32 | - }else |
|
32 | + } else |
|
33 | 33 | { |
34 | 34 | $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
35 | 35 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if(sizeof($e) == 2) |
53 | 53 | { |
54 | 54 | $query .= $this->$e[0]($e[1], 20) .", ".PHP_EOL; |
55 | - }else |
|
55 | + } else |
|
56 | 56 | { |
57 | 57 | $query .= $this->$e[0]($e[1], $e[2]) .", ".PHP_EOL; |
58 | 58 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | return true; |
96 | 96 | } |
97 | - }catch(PDOException $e){ |
|
97 | + } catch(PDOException $e){ |
|
98 | 98 | return $e->getMessage(); |
99 | 99 | } |
100 | 100 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Defining Interface for class DatabaseQueryInterface. |
|
4 | - * |
|
5 | - * @package Ibonly\PotatoORM\DatabaseQueryInterface |
|
6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | - */ |
|
3 | + * Defining Interface for class DatabaseQueryInterface. |
|
4 | + * |
|
5 | + * @package Ibonly\PotatoORM\DatabaseQueryInterface |
|
6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | namespace Ibonly\PotatoORM; |
11 | 11 |
@@ -11,9 +11,9 @@ |
||
11 | 11 | |
12 | 12 | interface DatabaseQueryInterface |
13 | 13 | { |
14 | - public function checkTableExist($table, $con=NULL); |
|
14 | + public function checkTableExist($table, $con = NULL); |
|
15 | 15 | |
16 | - public static function checkTableName($table, $dbConnection=NULL); |
|
16 | + public static function checkTableName($table, $dbConnection = NULL); |
|
17 | 17 | |
18 | 18 | public static function selectQuery($tableName, $field, $value, $connection); |
19 | 19 |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Defining Interface for class GetData. |
|
4 | - * |
|
5 | - * @package Ibonly\PotatoORM\ModelInterface |
|
6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | - */ |
|
3 | + * Defining Interface for class GetData. |
|
4 | + * |
|
5 | + * @package Ibonly\PotatoORM\ModelInterface |
|
6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | namespace Ibonly\PotatoORM; |
11 | 11 |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Defining Interface for class Model. |
|
4 | - * |
|
5 | - * @package Ibonly\PotatoORM\ModelInterface |
|
6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | - */ |
|
3 | + * Defining Interface for class Model. |
|
4 | + * |
|
5 | + * @package Ibonly\PotatoORM\ModelInterface |
|
6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | namespace Ibonly\PotatoORM; |
11 | 11 |