| Conditions | 11 |
| Paths | 15 |
| Total Lines | 64 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 46 | public function readAction($id = null, $redirect = null) |
||
| 47 | { |
||
| 48 | $projet = Projet::findFirst($id); |
||
| 49 | $usecases = Usecase::find("idProjet = $id"); |
||
| 50 | $messages = Message::find("idProjet = $id"); |
||
| 51 | $colorTexte = "black"; |
||
| 52 | |||
| 53 | $color = $projet->getDominantColor(); |
||
| 54 | |||
| 55 | //Si jamais la couleur retournée est noire, alors change sa couleur en gris clair |
||
| 56 | if ($color["r"] == 0 && $color["g"] == 0 && $color["b"] == 0) { |
||
| 57 | $color["r"] = 240; |
||
| 58 | $color["g"] = 240; |
||
| 59 | $color["b"] = 240; |
||
| 60 | //Sinon si la couleur est trop sombre change l'écriture en blanc pour qu'elle sois visible |
||
| 61 | } elseif ($color["r"] < 120 || $color["g"] < 120 || $color["b"] < 120) { |
||
| 62 | $colorTexte = "white"; |
||
| 63 | $color["r"] += 70; |
||
| 64 | $color["g"] += 70; |
||
| 65 | $color["b"] += 70; |
||
| 66 | } |
||
| 67 | |||
| 68 | $avancementReel = $this->avancementReel($usecases); |
||
| 69 | |||
| 70 | //Passage des différentes variables |
||
| 71 | $this->view->setVar("colorTexte", $colorTexte); |
||
| 72 | $this->view->setVar("color", $color); |
||
| 73 | $this->view->setVar("projet", $projet); |
||
| 74 | $this->view->setVar("messages", $messages); |
||
| 75 | $this->view->setVar("usecases", $usecases); |
||
| 76 | $this->view->setVar("avancement", $avancementReel); |
||
| 77 | |||
| 78 | //Création de la progressbar |
||
| 79 | $progress = $this->jquery->bootstrap()->htmlProgressbar("progress", "info", $avancementReel); |
||
| 80 | $progress->showcaption(true); |
||
| 81 | $this->jquery->get("Projets/resume/$id", "#contentProjet"); |
||
| 82 | //Creation des évenements onClick et des éléments sur le menu |
||
| 83 | $this->jquery->getOnClick("#menu1", "Projets/resume/$id", "#contentProjet"); |
||
| 84 | $this->jquery->getOnClick("#menu2", "Projets/contributors/$id", "#contentProjet"); |
||
| 85 | $this->jquery->getOnClick("#menu3", "Projets/usecases/$id", "#contentProjet"); |
||
| 86 | $this->jquery->getOnClick("#menu5", "Projets/messages/$id", "#contentProjet"); |
||
| 87 | |||
| 88 | if($redirect != null){ |
||
| 89 | switch($redirect){ |
||
| 90 | case(1): |
||
| 91 | $this->jquery->get("Projets/contributors/$id", "#contentProjet"); |
||
| 92 | break; |
||
| 93 | case(2): |
||
| 94 | $this->jquery->get("Projets/usecases/$id", "#contentProjet"); |
||
| 95 | break; |
||
| 96 | case(3): |
||
| 97 | $this->jquery->get("Projets/messages/$id", "#contentProjet"); |
||
| 98 | break; |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | |||
| 103 | //Xeditable |
||
| 104 | $this->jquery->exec("$('#nom').editable()", true); |
||
| 105 | $this->jquery->exec("$('#image').editable()", true); |
||
| 106 | |||
| 107 | //Compilation de Jquery dans la vue |
||
| 108 | $this->jquery->compile($this->view); |
||
| 109 | } |
||
| 110 | |||
| 229 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.