Completed
Push — develop ( b9059c...aba1ed )
by Oyebanji Jacob
02:10
created
src/DatabaseConnectionStringFactory.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@
 block discarded – undo
18 18
 
19 19
         switch ($driver) {
20 20
             case 'sqlite':
21
-                $dsn = $driver.'::memory:';
21
+                $dsn = $driver . '::memory:';
22 22
                 break;
23 23
             case 'mysql':
24 24
             case 'postgres':
25
-                if(strcasecmp($driver, 'postgres') == 0) $driver="pgsql";
26
-                $dsn = $driver.':host='.$config['HOSTNAME'].';dbname='.$config['DBNAME'];
27
-                if(isset($config['PORT'])) $dsn .= ';port='.$config['PORT'];
25
+                if (strcasecmp($driver, 'postgres') == 0) $driver = "pgsql";
26
+                $dsn = $driver . ':host=' . $config['HOSTNAME'] . ';dbname=' . $config['DBNAME'];
27
+                if (isset($config['PORT'])) $dsn .= ';port=' . $config['PORT'];
28 28
                 break;
29 29
             default:
30 30
                 throw new DatabaseDriverNotSupportedException;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,13 @@
 block discarded – undo
22 22
                 break;
23 23
             case 'mysql':
24 24
             case 'postgres':
25
-                if(strcasecmp($driver, 'postgres') == 0) $driver="pgsql";
25
+                if(strcasecmp($driver, 'postgres') == 0) {
26
+                    $driver="pgsql";
27
+                }
26 28
                 $dsn = $driver.':host='.$config['HOSTNAME'].';dbname='.$config['DBNAME'];
27
-                if(isset($config['PORT'])) $dsn .= ';port='.$config['PORT'];
29
+                if(isset($config['PORT'])) {
30
+                    $dsn .= ';port='.$config['PORT'];
31
+                }
28 32
                 break;
29 33
             default:
30 34
                 throw new DatabaseDriverNotSupportedException;
Please login to merge, or discard this patch.
src/Model.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -10,21 +10,21 @@  discard block
 block discarded – undo
10 10
 
11 11
     /**
12 12
      * Store instance of database connection used.
13
-    * @var [type]
14
-    */
13
+     * @var [type]
14
+     */
15 15
     protected  $databaseConnection;
16 16
 
17 17
     /**
18 18
      *  The id of the model.
19 19
      *  
20 20
      * @property string $id
21
-    */
21
+     */
22 22
      
23 23
     /**
24 24
      * Create a model instance.
25 25
      * 
26 26
      */
27
-     public function __construct()
27
+        public function __construct()
28 28
     {
29 29
         $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection;
30 30
        
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
     /**
33 33
      * Sets into $properties the $key => $value pairs
34 34
      * 
35
-    * @param string $key 
36
-    * @param string $val 
37
-    *
38
-    */
35
+     * @param string $key 
36
+     * @param string $val 
37
+     *
38
+     */
39 39
     public  function __set($key, $val)
40 40
     {
41 41
         $this->properties[$key] = $val;
42 42
     }
43 43
     /**
44
-    * @param string $key
45
-    * 
46
-    * @return array
47
-    */
44
+     * @param string $key
45
+     * 
46
+     * @return array
47
+     */
48 48
     public function __get($key)
49 49
     {
50 50
         return $this->properties[$key];
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @return array
56 56
      */
57
-     public function getProperties()
58
-     {
59
-         return $this->properties;
60
-     }
57
+        public function getProperties()
58
+        {
59
+            return $this->properties;
60
+        }
61 61
     /**
62
-    * Gets the name of the child class with a 's'.
63
-    *
64
-    * @return string
65
-    */
62
+     * Gets the name of the child class with a 's'.
63
+     *
64
+     * @return string
65
+     */
66 66
     public function getTableName()
67 67
     {
68 68
         $className = explode('\\', get_called_class());
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
         return $table;
71 71
     }
72 72
     /**
73
-    * Find the particular model with the passed id.
74
-    * 
75
-    * @param int $id
76
-    * 
77
-    * @return object
78
-    */
73
+     * Find the particular model with the passed id.
74
+     * 
75
+     * @param int $id
76
+     * 
77
+     * @return object
78
+     */
79 79
     public static function find($id)
80 80
     {
81 81
         $model = new static;
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
     /**
86
-    * Get the particular model with the passed id.
87
-    * 
88
-    * @param int $id
89
-    * 
90
-    * @return object
91
-    */
86
+     * Get the particular model with the passed id.
87
+     * 
88
+     * @param int $id
89
+     * 
90
+     * @return object
91
+     */
92 92
     public function get($id)
93 93
     {
94 94
         $sql = "SELECT * FROM {$this->getTableName()} WHERE id={$id}";
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
     }
103 103
 
104 104
     /**
105
-    * Get all the models from the database.
106
-    * 
107
-    * @return array
108
-    */
105
+     * Get all the models from the database.
106
+     * 
107
+     * @return array
108
+     */
109 109
     public static function getAll()
110 110
     {
111 111
         $model = new static;
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
     }
114 114
 
115 115
     /**
116
-    * Returns all the models from the database.
117
-    * 
118
-    * @return array
119
-    */
116
+     * Returns all the models from the database.
117
+     * 
118
+     * @return array
119
+     */
120 120
     public function all()
121 121
     {
122 122
         $sql = "SELECT * FROM {$this->getTableName()}";
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      * Update the model in the database.
131 131
      * 
132 132
      * @return int
133
-    */
133
+     */
134 134
     private function update()
135 135
     {
136 136
        
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
     }
152 152
 
153 153
     /**
154
-    * Insert the model values into the database.
155
-    *
156
-    * @return int
157
-    */
154
+     * Insert the model values into the database.
155
+     *
156
+     * @return int
157
+     */
158 158
     private function create()
159 159
     {
160 160
         
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
         return $this->id ? $this->update() : $this->create();
190 190
     }
191 191
 
192
-   /**
193
-    * Delete a model from the database. 
194
-    * @param  int $id 
195
-    * @return boolean
196
-    */
192
+    /**
193
+     * Delete a model from the database. 
194
+     * @param  int $id 
195
+     * @return boolean
196
+     */
197 197
     public static function destroy($id)
198 198
     {
199 199
         $model = new static;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function getTableName()
67 67
     {
68 68
         $className = explode('\\', get_called_class());
69
-        $table = strtolower(end($className) .'s');
69
+        $table = strtolower(end($className) . 's');
70 70
         return $table;
71 71
     }
72 72
     /**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $sqlStatement = $this->databaseConnection->prepare($sql);
96 96
         $sqlStatement->setFetchMode($this->databaseConnection::FETCH_CLASS, get_called_class());
97 97
         $sqlStatement->execute();
98
-        if($sqlStatement->rowCount() < 1){
98
+        if ($sqlStatement->rowCount() < 1) {
99 99
             throw new ModelNotFoundException($id);
100 100
         }
101 101
         return $sqlStatement->fetch();
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
     {
136 136
        
137 137
         $bindNameParameters = [];
138
-        $sqlUpdate = "UPDATE " . $this->getTableName() . " SET " ;
138
+        $sqlUpdate = "UPDATE " . $this->getTableName() . " SET ";
139 139
         foreach ($this->properties as $columnName => $columnValue) {
140
-            if($columnName == 'id') continue;
140
+            if ($columnName == 'id') continue;
141 141
             $bindColumnName = ':' . $columnName;
142 142
             $sqlUpdate .= "$columnName = $bindColumnName,";
143 143
             $bindNameParameters[$bindColumnName] = $columnValue;
144 144
         }
145 145
         //Remove the last comma in sql command then join it to the other query part.
146
-        $sqlUpdate = substr($sqlUpdate, 0, -1)." WHERE id = :id";
146
+        $sqlUpdate = substr($sqlUpdate, 0, -1) . " WHERE id = :id";
147 147
         $sqlStatement = $this->databaseConnection->prepare($sqlUpdate);
148 148
         $sqlStatement->bindValue(":id", $this->properties['id']);
149 149
         $sqlStatement->execute($bindNameParameters);
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
         $columnNames = "";
162 162
         $columnValues = "";
163 163
         $bindNameParameters = [];
164
-        $sqlCreate = "INSERT" . " INTO " . $this->getTableName()." (";
164
+        $sqlCreate = "INSERT" . " INTO " . $this->getTableName() . " (";
165 165
         foreach ($this->properties as $columnName => $columnValue) {
166 166
 
167 167
             $bindColumnName = ':' . $columnName;
168
-            $columnNames .= $columnName.",";
169
-            $columnValues .= $bindColumnName.",";
168
+            $columnNames .= $columnName . ",";
169
+            $columnValues .= $bindColumnName . ",";
170 170
             $bindNameParameters[$bindColumnName] = $columnValue;
171 171
         }
172 172
         // Remove ending comma and whitespace.
173 173
         $columnNames = substr($columnNames, 0, -1);
174 174
         $columnValues = substr($columnValues, 0, -1);
175 175
 
176
-        $sqlCreate .= $columnNames.') VALUES (' .$columnValues.')';
176
+        $sqlCreate .= $columnNames . ') VALUES (' . $columnValues . ')';
177 177
         $sqlStatement = $this->databaseConnection->prepare($sqlCreate);
178 178
         $sqlStatement->execute($bindNameParameters);
179 179
         return $sqlStatement->rowCount();
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function delete($id)
210 210
     {
211
-        $sql = "DELETE" . " FROM " . self::getTableName()." WHERE id = ". $id;
211
+        $sql = "DELETE" . " FROM " . self::getTableName() . " WHERE id = " . $id;
212 212
         $sqlStatment = $this->databaseConnection->prepare($sql);
213 213
         $sqlStatment->execute();
214 214
         return ($sqlStatment->rowCount() > 0) ? true : false;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,9 @@
 block discarded – undo
137 137
         $bindNameParameters = [];
138 138
         $sqlUpdate = "UPDATE " . $this->getTableName() . " SET " ;
139 139
         foreach ($this->properties as $columnName => $columnValue) {
140
-            if($columnName == 'id') continue;
140
+            if($columnName == 'id') {
141
+                continue;
142
+            }
141 143
             $bindColumnName = ':' . $columnName;
142 144
             $sqlUpdate .= "$columnName = $bindColumnName,";
143 145
             $bindNameParameters[$bindColumnName] = $columnValue;
Please login to merge, or discard this patch.
test/DatabaseConnectionStringFactoryTest.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@  discard block
 block discarded – undo
5 5
 
6 6
 class DatabaseConnectionStringFactoryTest extends PHPUnit_Framework_TestCase
7 7
 {
8
-     /**
9
-     * The instance of DatabaseConnectionStringFactory used in the test.
10
-     *
11
-     * @var Pyjac\ORM\DatabaseConnectionStringFactory
12
-     */
8
+        /**
9
+         * The instance of DatabaseConnectionStringFactory used in the test.
10
+         *
11
+         * @var Pyjac\ORM\DatabaseConnectionStringFactory
12
+         */
13 13
     protected $databaseConnectionStringFactoryTest;
14 14
 
15 15
     /**
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
         $this->assertEquals("sqlite::memory:", $dsn);
46 46
     }
47 47
 
48
-     /**
49
-     * @expectedException Pyjac\ORM\Exception\DatabaseDriverNotSupportedException
50
-     */
48
+        /**
49
+         * @expectedException Pyjac\ORM\Exception\DatabaseDriverNotSupportedException
50
+         */
51 51
     public function testCreateDatabaseSourceStringThrowsDatabaseDriverNotSupportedExceptionWhenUnknownDriverIsPassed()
52 52
     {
53 53
         $this->config['DRIVER']= 'pyjac';
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,21 +26,21 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function testCreateDatabaseSourceStringReturnsCorrectPostgresDatabaseSourceString()
28 28
     {
29
-        $this->config['DRIVER']= 'postgres';
29
+        $this->config['DRIVER'] = 'postgres';
30 30
         $dsn = $this->databaseConnectionStringFactory->createDatabaseSourceString($this->config);
31 31
         $this->assertEquals("pgsql:host=localhost;dbname=Pyjac", $dsn);
32 32
     }
33 33
 
34 34
     public function testCreateDatabaseSourceStringReturnsCorrectMYSqlDatabaseSourceString()
35 35
     {
36
-        $this->config['DRIVER']= 'mysql';
36
+        $this->config['DRIVER'] = 'mysql';
37 37
         $dsn = $this->databaseConnectionStringFactory->createDatabaseSourceString($this->config);
38 38
         $this->assertEquals("mysql:host=localhost;dbname=Pyjac", $dsn);
39 39
     }
40 40
 
41 41
     public function testCreateDatabaseSourceStringReturnsCorrectSQLiteDatabaseSourceString()
42 42
     {
43
-        $this->config['DRIVER']= 'sqlite';
43
+        $this->config['DRIVER'] = 'sqlite';
44 44
         $dsn = $this->databaseConnectionStringFactory->createDatabaseSourceString($this->config);
45 45
         $this->assertEquals("sqlite::memory:", $dsn);
46 46
     }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function testCreateDatabaseSourceStringThrowsDatabaseDriverNotSupportedExceptionWhenUnknownDriverIsPassed()
52 52
     {
53
-        $this->config['DRIVER']= 'pyjac';
53
+        $this->config['DRIVER'] = 'pyjac';
54 54
         $dsn = $this->databaseConnectionStringFactory->createDatabaseSourceString($this->config);
55 55
     }
56 56
 }
57 57
\ No newline at end of file
Please login to merge, or discard this patch.
test/HelpersTest.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
24 24
         ];
25 25
     }
26 26
     public function testContainsReturnsFalseWhenStringNotFoundInArray()
27
-     {
27
+        {
28 28
         $this->assertFalse(Helpers::contains("PHP rocks", $this->testArray));
29 29
 
30
-     }
30
+        }
31 31
 
32 32
     public function testContainsReturnsTrueWhenStringIsFoundInArray()
33
-     {
33
+        {
34 34
         $this->assertTrue(Helpers::contains("Error while sending", $this->testArray));
35 35
 
36
-     }
36
+        }
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
test/DatabaseConnectionTest.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 
14 14
 
15
-	public function setUp(){
15
+	public function setUp() {
16 16
 		$databaseConnectionStringFactory =
17 17
                         m::mock('Pyjac\ORM\DatabaseConnectionStringFactoryInterface');
18 18
         $databaseConnectionStringFactory->shouldReceive('createDatabaseSourceString')
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
 	 * Reference: https://jtreminio.com/2013/03/unit-testing-tutorial-part-3-testing-protected-private-methods-coverage-reports-and-crap/
74 74
 	* Call protected/private method of a class.
75 75
 	*
76
-	* @param object &$object    Instantiated object that we will run method on.
76
+	* @param object DatabaseConnection    Instantiated object that we will run method on.
77 77
 	* @param string $methodName Method name to call
78 78
 	* @param array  $parameters Array of parameters to pass into method.
79 79
 	*
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -5,86 +5,86 @@
 block discarded – undo
5 5
 
6 6
 class DatabaseConnectionTest extends PHPUnit_Framework_TestCase
7 7
 {
8
-	/**
9
-	 * instance of DatabaseConnection used in test.
10
-	 */
11
-	protected $databaseConnection;
8
+    /**
9
+     * instance of DatabaseConnection used in test.
10
+     */
11
+    protected $databaseConnection;
12 12
 
13 13
 
14 14
 
15
-	public function setUp(){
16
-		$databaseConnectionStringFactory =
15
+    public function setUp(){
16
+        $databaseConnectionStringFactory =
17 17
                         m::mock('Pyjac\ORM\DatabaseConnectionStringFactoryInterface');
18 18
         $databaseConnectionStringFactory->shouldReceive('createDatabaseSourceString')
19
-                                             ->with(['DRIVER' => 'sqlite', 'HOSTNAME' => '127.0.0.1', 'USERNAME' => '', 'PASSWORD' => '', 'DBNAME' => 'potatoORM', 'PORT' => '54320'])->once()->andReturn('sqlite::memory:');
19
+                                                ->with(['DRIVER' => 'sqlite', 'HOSTNAME' => '127.0.0.1', 'USERNAME' => '', 'PASSWORD' => '', 'DBNAME' => 'potatoORM', 'PORT' => '54320'])->once()->andReturn('sqlite::memory:');
20 20
 
21 21
         $this->databaseConnection = new DatabaseConnection($databaseConnectionStringFactory);
22
-	}
22
+    }
23 23
 
24
-	public function testCreateConnectionReturnsDatabaseConnection()
25
-	{
26
-		$dbInstance = $this->databaseConnection->createConnection('sqlite::memory:');
24
+    public function testCreateConnectionReturnsDatabaseConnection()
25
+    {
26
+        $dbInstance = $this->databaseConnection->createConnection('sqlite::memory:');
27 27
 
28
-		$this->assertInstanceOf('PDO', $dbInstance);
28
+        $this->assertInstanceOf('PDO', $dbInstance);
29 29
 
30
-	}
30
+    }
31 31
 
32
-	public function testGetInstanceReturnsCorrectInstance()
33
-	{
34
-		$dbInstance = DatabaseConnection::getInstance();
32
+    public function testGetInstanceReturnsCorrectInstance()
33
+    {
34
+        $dbInstance = DatabaseConnection::getInstance();
35 35
 
36
-		$this->assertInstanceOf('Pyjac\ORM\DatabaseConnection', $dbInstance);
36
+        $this->assertInstanceOf('Pyjac\ORM\DatabaseConnection', $dbInstance);
37 37
 
38
-	}
38
+    }
39 39
 
40
-	public function testSetOptionsAndGetOptionsReturnsCorrectValue()
41
-	{
42
-		$options = [
43
-	        PDO::ATTR_CASE => PDO::CASE_NATURAL,
44
-	        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
45
-	        PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
46
-	        PDO::ATTR_STRINGIFY_FETCHES => false,
47
-	        PDO::ATTR_EMULATE_PREPARES => false,
48
-	    ];
49
-		$this->databaseConnection->setDefaultOptions($options);
40
+    public function testSetOptionsAndGetOptionsReturnsCorrectValue()
41
+    {
42
+        $options = [
43
+            PDO::ATTR_CASE => PDO::CASE_NATURAL,
44
+            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
45
+            PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
46
+            PDO::ATTR_STRINGIFY_FETCHES => false,
47
+            PDO::ATTR_EMULATE_PREPARES => false,
48
+        ];
49
+        $this->databaseConnection->setDefaultOptions($options);
50 50
 
51
-		$this->assertEquals($this->databaseConnection->getDefaultOptions(), $options);
52
-	}
51
+        $this->assertEquals($this->databaseConnection->getDefaultOptions(), $options);
52
+    }
53 53
 
54
-	public function testTryAgainIfCausedByLostConnectionCreateNewConnectionWhenReasonForExceptionIsConnectionLoss()
55
-	{
56
-		 $e = new \Exception("Error while sending");
57
-		$result = $this->invokeMethod($this->databaseConnection, 'tryAgainIfCausedByLostConnection', [$e, 'sqlite::memory:', '', '', []]);
54
+    public function testTryAgainIfCausedByLostConnectionCreateNewConnectionWhenReasonForExceptionIsConnectionLoss()
55
+    {
56
+            $e = new \Exception("Error while sending");
57
+        $result = $this->invokeMethod($this->databaseConnection, 'tryAgainIfCausedByLostConnection', [$e, 'sqlite::memory:', '', '', []]);
58 58
 
59
-		$this->assertInstanceOf('PDO', $result);
60
-	}
59
+        $this->assertInstanceOf('PDO', $result);
60
+    }
61 61
 
62
-	/**
62
+    /**
63 63
      * @expectedException \Exception
64 64
      */
65
-	public function testTryAgainIfCausedByLostConnectionThrowsExceptionWhenReasonForExceptionIsNotConnectionLoss()
66
-	{
67
-		$e = new \Exception("PHP Rocks !!!");
68
-		$result = $this->invokeMethod($this->databaseConnection, 'tryAgainIfCausedByLostConnection', [$e, 'sqlite::memory:', '', '', []]);
69
-
70
-	}
71
-
72
-	/**
73
-	 * Reference: https://jtreminio.com/2013/03/unit-testing-tutorial-part-3-testing-protected-private-methods-coverage-reports-and-crap/
74
-	* Call protected/private method of a class.
75
-	*
76
-	* @param object &$object    Instantiated object that we will run method on.
77
-	* @param string $methodName Method name to call
78
-	* @param array  $parameters Array of parameters to pass into method.
79
-	*
80
-	* @return mixed Method return.
81
-	*/
82
-	public function invokeMethod(&$object, $methodName, array $parameters = array())
83
-	{
84
-		$reflection = new \ReflectionClass(get_class($object));
85
-		$method = $reflection->getMethod($methodName);
86
-		$method->setAccessible(true);
87
-
88
-		return $method->invokeArgs($object, $parameters);
89
-	}
65
+    public function testTryAgainIfCausedByLostConnectionThrowsExceptionWhenReasonForExceptionIsNotConnectionLoss()
66
+    {
67
+        $e = new \Exception("PHP Rocks !!!");
68
+        $result = $this->invokeMethod($this->databaseConnection, 'tryAgainIfCausedByLostConnection', [$e, 'sqlite::memory:', '', '', []]);
69
+
70
+    }
71
+
72
+    /**
73
+     * Reference: https://jtreminio.com/2013/03/unit-testing-tutorial-part-3-testing-protected-private-methods-coverage-reports-and-crap/
74
+     * Call protected/private method of a class.
75
+     *
76
+     * @param object &$object    Instantiated object that we will run method on.
77
+     * @param string $methodName Method name to call
78
+     * @param array  $parameters Array of parameters to pass into method.
79
+     *
80
+     * @return mixed Method return.
81
+     */
82
+    public function invokeMethod(&$object, $methodName, array $parameters = array())
83
+    {
84
+        $reflection = new \ReflectionClass(get_class($object));
85
+        $method = $reflection->getMethod($methodName);
86
+        $method->setAccessible(true);
87
+
88
+        return $method->invokeArgs($object, $parameters);
89
+    }
90 90
 }
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
test/ModelTest.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
 
5 5
 class ModelTest extends PHPUnit_Framework_TestCase
6 6
 {
7
-	protected $model;
7
+    protected $model;
8 8
 
9
-	public function setUp(){
10
-		$this->model =  $this->getMockForAbstractClass('Pyjac\ORM\Model');
11
-	}
9
+    public function setUp(){
10
+        $this->model =  $this->getMockForAbstractClass('Pyjac\ORM\Model');
11
+    }
12 12
 
13
-	public function testGetTableNameReturnsCorrectTableName()
13
+    public function testGetTableNameReturnsCorrectTableName()
14 14
     {
15 15
         $this->model->expects($this->any())
16
-             ->method('getTableName')
17
-             ->will($this->returnValue(strtolower(get_class($this->model).'s')));
16
+                ->method('getTableName')
17
+                ->will($this->returnValue(strtolower(get_class($this->model).'s')));
18 18
 
19 19
         $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model).'s'));
20 20
     }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
     public function testGetTableNameReturnsCorrectTableName2()
23 23
     {
24 24
         $this->model->expects($this->any())
25
-             ->method('getTableName')
26
-             ->will($this->returnValue(strtolower(get_class($this->model).'s')));
25
+                ->method('getTableName')
26
+                ->will($this->returnValue(strtolower(get_class($this->model).'s')));
27 27
 
28 28
         $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model).'s'));
29 29
     }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 {
7 7
 	protected $model;
8 8
 
9
-	public function setUp(){
10
-		$this->model =  $this->getMockForAbstractClass('Pyjac\ORM\Model');
9
+	public function setUp() {
10
+		$this->model = $this->getMockForAbstractClass('Pyjac\ORM\Model');
11 11
 	}
12 12
 
13 13
 	public function testGetTableNameReturnsCorrectTableName()
14 14
     {
15 15
         $this->model->expects($this->any())
16 16
              ->method('getTableName')
17
-             ->will($this->returnValue(strtolower(get_class($this->model).'s')));
17
+             ->will($this->returnValue(strtolower(get_class($this->model) . 's')));
18 18
 
19
-        $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model).'s'));
19
+        $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model) . 's'));
20 20
     }
21 21
 
22 22
     public function testGetTableNameReturnsCorrectTableName2()
23 23
     {
24 24
         $this->model->expects($this->any())
25 25
              ->method('getTableName')
26
-             ->will($this->returnValue(strtolower(get_class($this->model).'s')));
26
+             ->will($this->returnValue(strtolower(get_class($this->model) . 's')));
27 27
 
28
-        $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model).'s'));
28
+        $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model) . 's'));
29 29
     }
30 30
 
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
src/DatabaseConnectionInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 interface DatabaseConnectionInterface 
6 6
 {
7
-	/**
7
+    /**
8 8
      * Get the instance of the class.
9 9
      *     
10 10
      * @return Pyjac\ORM\DatabaseConnection
Please login to merge, or discard this patch.