Completed
Push — master ( 3f730a...0a85bc )
by Anthony
02:06
created

Comment::getRender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
	namespace modules\comment\app\controller;
3
	
4
	
5
	use core\App;
6
	
7
	class Comment {
8
		//-------------------------- BUILDER ----------------------------------------------------------------------------//
9
		//-------------------------- END BUILDER ----------------------------------------------------------------------------//
10
		
11
		
12
		
13
		//-------------------------- GETTER ----------------------------------------------------------------------------//
14
		private function getRender($values) {
0 ignored issues
show
Unused Code introduced by
The parameter $values is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
15
			
16
		}
17
		
18
		/**
19
		 * @param $table
20
		 * @param $nom_id_table
21
		 * @param $id_in_table
22
		 * function wich get all comments of an other module like a article of a blog
23
		 * after all coments was getted it will call getRender to use twig to render them
24
		 */
25
		public function getComments($table, $nom_id_table, $id_in_table) {
26
			$dbc = App::getDb();
27
			
28
			$query = $dbc->select()->from("_comment_all")->where("nom_table", "=", $table, "AND")
29
				->where("nom_id_table", "=", $nom_id_table, "AND")->where("ID_in_table", "=", $id_in_table)->get();
30
			
31
			if (count($query) > 0) {
32
				$values = [];
33
				
34
				foreach ($query as $obj) {
35
					$values[] = [
36
						"comment" => $obj->comment,
37
						"date" => $obj->date,
38
						"first_name" => $obj->first_name,
39
						"last_name" => $obj->last_name,
40
						"ID_identite" => $obj->ID_identite,
41
					];
42
				}
43
				
44
				$this->getRender($values);
0 ignored issues
show
Unused Code introduced by
The call to the method modules\comment\app\cont...er\Comment::getRender() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
45
			}
46
		}
47
		//-------------------------- END GETTER ----------------------------------------------------------------------------//
48
		
49
		
50
		
51
		//-------------------------- SETTER ----------------------------------------------------------------------------//
52
		//-------------------------- END SETTER ----------------------------------------------------------------------------//
53
		
54
	}