@@ -90,9 +90,9 @@ public function getClassMetadata($className)
9090 /**
9191 * Gets the repository for an entity class.
9292 *
93- * @param string $entityName The name of the entity.
93+ * @param string $entityName the name of the entity
9494 *
95- * @return \CassandraBundle\Cassandra\ORM\EntityRepository The repository class.
95+ * @return \CassandraBundle\Cassandra\ORM\EntityRepository the repository class
9696 */
9797 public function getRepository ($ entityName )
9898 {
@@ -102,12 +102,12 @@ public function getRepository($entityName)
102102 /**
103103 * Insert $entity to cassandra.
104104 *
105- * @param object $entity
105+ * @param object $entity
106106 * @param Options $options |null
107107 */
108108 public function insert ($ entity , Options $ options = null )
109109 {
110- $ metadata = $ this ->getClassMetadata (get_class ($ entity ));
110+ $ metadata = $ this ->getClassMetadata (\ get_class ($ entity ));
111111 $ tableName = $ metadata ->table ['name ' ];
112112 $ values = $ this ->readColumn ($ entity , $ metadata );
113113 $ columns = array_keys ($ values );
@@ -130,10 +130,12 @@ public function insert($entity, Options $options = null)
130130 }
131131
132132 /**
133- * add options to statement
133+ * add options to statement.
134+ *
134135 * @param $statement
135136 * @param ClassMetadata $metadata
136- * @param Options|null $options
137+ * @param Options|null $options
138+ *
137139 * @return string
138140 */
139141 private function decorateInsertStatement ($ statement , ClassMetadata $ metadata , Options $ options = null )
@@ -144,17 +146,18 @@ private function decorateInsertStatement($statement, ClassMetadata $metadata, Op
144146 $ statement .= ' IF NOT EXISTS ' ;
145147 }
146148 if (!empty ($ options ) && !empty ($ options ->getTtl ())) {
147- $ statement .= ' USING TTL ' . $ options ->getTtl ();
149+ $ statement .= ' USING TTL ' . $ options ->getTtl ();
148150 } elseif (!empty ($ metadata ->table ['defaultTtl ' ])) {
149- $ statement .= ' USING TTL ' . $ metadata ->table ['defaultTtl ' ];
151+ $ statement .= ' USING TTL ' . $ metadata ->table ['defaultTtl ' ];
150152 }
153+
151154 return $ statement ;
152155 }
153156
154157 /**
155158 * Update $entity to cassandra.
156159 *
157- * @param object $entity
160+ * @param object $entity
158161 * @param Options|null $options
159162 *
160163 * @deprecated update method will be deprecated since version 1.3 and will be removed in 1.5
@@ -171,7 +174,7 @@ public function update($entity, Options $options = null)
171174 */
172175 public function delete ($ entity )
173176 {
174- $ metadata = $ this ->getClassMetadata (get_class ($ entity ));
177+ $ metadata = $ this ->getClassMetadata (\ get_class ($ entity ));
175178 $ tableName = $ metadata ->table ['name ' ];
176179
177180 $ statement = sprintf (
@@ -191,12 +194,12 @@ public function delete($entity)
191194 */
192195 public function flush ($ async = true )
193196 {
194- if (count ($ this ->statements )) {
197+ if (\ count ($ this ->statements )) {
195198 $ this ->logger ->debug ('CASSANDRA: BEGIN ' );
196199 $ batch = new BatchStatement (\Cassandra::BATCH_LOGGED );
197200
198201 foreach ($ this ->statements as $ statement ) {
199- $ this ->logger ->debug ('CASSANDRA: ' . $ statement [self ::STATEMENT ] . ' => ' . json_encode ($ statement [self ::ARGUMENTS ]));
202+ $ this ->logger ->debug ('CASSANDRA: ' . $ statement [self ::STATEMENT ]. ' => ' . json_encode ($ statement [self ::ARGUMENTS ]));
200203 $ batch ->add ($ this ->prepare ($ statement [self ::STATEMENT ]), $ statement [self ::ARGUMENTS ]);
201204 }
202205
@@ -220,9 +223,9 @@ public function flush($async = true)
220223 private function readColumn ($ entity , $ metadata )
221224 {
222225 foreach ($ metadata ->fieldMappings as $ field ) {
223- $ getterMethod = 'get ' . ucfirst ($ field ['fieldName ' ]);
226+ $ getterMethod = 'get ' . ucfirst ($ field ['fieldName ' ]);
224227 if (null !== $ entity ->{$ getterMethod }()) {
225- if ($ this ->isCassandraType ($ entity ->{$ getterMethod }())) {
228+ if ($ this ->isCassandraType ($ entity ->{$ getterMethod }())) {
226229 $ values [$ field ['columnName ' ]] = $ entity ->{$ getterMethod }();
227230 } else {
228231 $ values [$ field ['columnName ' ]] = $ this ->encodeColumnType ($ field ['type ' ], $ entity ->{$ getterMethod }());
@@ -242,20 +245,21 @@ private function readColumn($entity, $metadata)
242245 */
243246 private function isCassandraType ($ obj )
244247 {
245- $ classNames = array ( '\Cassandra\Collection ' , '\Cassandra\Custom ' , '\Cassandra\Map ' , '\Cassandra\Scalar ' , '\Cassandra\Set ' , '\Cassandra\Tuple ' , '\Cassandra\UserType ' ) ;
248+ $ classNames = [ '\Cassandra\Collection ' , '\Cassandra\Custom ' , '\Cassandra\Map ' , '\Cassandra\Scalar ' , '\Cassandra\Set ' , '\Cassandra\Tuple ' , '\Cassandra\UserType ' ] ;
246249 foreach ($ classNames as $ className ) {
247250 if (is_a ($ obj , $ className )) {
248251 return true ;
249252 }
250253 }
254+
251255 return false ;
252256 }
253257
254258 /**
255259 * Return $value with appropriate $type.
256260 *
257261 * @param string $type
258- * @param mixed $value
262+ * @param mixed $value
259263 *
260264 * @return mixed
261265 */
@@ -297,28 +301,28 @@ private function encodeColumnType($type, $value = null)
297301
298302 private function decodeColumnType ($ columnValue )
299303 {
300- if ($ columnValue === null ) {
304+ if (null === $ columnValue ) {
301305 return $ columnValue ;
302306 }
303307
304308 try {
305- if (is_bool ($ columnValue )) {
309+ if (\ is_bool ($ columnValue )) {
306310 return $ columnValue ;
307311 }
308312 // Cassandra\Timestamp class
309- if ($ columnValue instanceOf \Cassandra \Timestamp) {
313+ if ($ columnValue instanceof \Cassandra \Timestamp) {
310314 return $ columnValue ->time ();
311315 }
312316 // Cassandra\Date class
313- if ($ columnValue instanceOf \Cassandra \Date) {
317+ if ($ columnValue instanceof \Cassandra \Date) {
314318 return $ columnValue ->seconds ();
315319 }
316320 // Cassandra\Time class
317- if ($ columnValue instanceOf \Cassandra \Time) {
321+ if ($ columnValue instanceof \Cassandra \Time) {
318322 return $ columnValue ->seconds ();
319323 }
320324 // Cassandra\Map class
321- if ($ columnValue instanceOf \Cassandra \Map) {
325+ if ($ columnValue instanceof \Cassandra \Map) {
322326 $ decodedKeys = [];
323327 foreach ($ columnValue ->keys () as $ key ) {
324328 $ decodedKeys [] = $ this ->decodeColumnType ($ key );
@@ -331,7 +335,7 @@ private function decodeColumnType($columnValue)
331335 return array_combine ($ decodedKeys , $ decodedValues );
332336 }
333337 // Cassandra\Set class
334- if ($ columnValue instanceOf \Cassandra \Set) {
338+ if ($ columnValue instanceof \Cassandra \Set) {
335339 $ decodedValues = [];
336340 foreach ($ columnValue ->values () as $ value ) {
337341 $ decodedValues [] = $ this ->decodeColumnType ($ value );
@@ -340,7 +344,7 @@ private function decodeColumnType($columnValue)
340344 return $ decodedValues ;
341345 }
342346
343- return (string )$ columnValue ;
347+ return (string ) $ columnValue ;
344348 } catch (\Exception $ e ) {
345349 return $ columnValue ->values ();
346350 }
@@ -361,10 +365,10 @@ public function cleanRow($cassandraRow)
361365 /**
362366 * Finds an Entity by its identifier.
363367 *
364- * @param ClassMetadata $metadata The metadata of the entity to find.
365- * @param mixed $id The identity of the entity to find.
368+ * @param ClassMetadata $metadata the metadata of the entity to find
369+ * @param mixed $id the identity of the entity to find
366370 *
367- * @return object|null The entity instance or NULL if the entity can not be found.
371+ * @return object|null the entity instance or NULL if the entity can not be found
368372 */
369373 public function find (ClassMetadata $ metadata , $ id )
370374 {
@@ -374,7 +378,7 @@ public function find(ClassMetadata $metadata, $id)
374378 try {
375379 $ query ->addParameter ($ id , 'uuid ' );
376380 } catch (\Cassandra \Exception \InvalidArgumentException $ e ) {
377- $ this ->logger ->error ('CASSANDRA: ' . $ e ->getMessage ());
381+ $ this ->logger ->error ('CASSANDRA: ' . $ e ->getMessage ());
378382
379383 return ;
380384 }
@@ -386,11 +390,11 @@ public function find(ClassMetadata $metadata, $id)
386390 }
387391
388392 /**
389- * Finds all entities
393+ * Finds all entities.
390394 *
391- * @param ClassMetadata $metadata The metadata of the entity to find.
395+ * @param ClassMetadata $metadata the metadata of the entity to find
392396 *
393- * @return ArrayCollection The array of entity instance or empty array if the entity can not be found.
397+ * @return ArrayCollection the array of entity instance or empty array if the entity can not be found
394398 */
395399 public function findAll (ClassMetadata $ metadata )
396400 {
0 commit comments