@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @version 1.001 |
11 | 11 | */ |
12 | 12 | abstract class BaseComponent { |
13 | - public $jquery_code_for_compile=array (); |
|
14 | - protected $params=array (); |
|
13 | + public $jquery_code_for_compile=array(); |
|
14 | + protected $params=array(); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function setParams($params) { |
71 | - if(\is_array($params)) { |
|
71 | + if (\is_array($params)) { |
|
72 | 72 | foreach ($params as $k => $v) { |
73 | - $method = "set" . ucfirst($k); |
|
73 | + $method="set".ucfirst($k); |
|
74 | 74 | if (method_exists($this, $method)) |
75 | 75 | $this->$method($v); |
76 | 76 | else { |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function addParams($params){ |
|
87 | - foreach ($params as $k=>$v){ |
|
86 | + public function addParams($params) { |
|
87 | + foreach ($params as $k=>$v) { |
|
88 | 88 | $this->setParam($k, $v); |
89 | 89 | } |
90 | 90 | return $this; |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | |
93 | 93 | abstract public function getScript(); |
94 | 94 | |
95 | - public function setDebug($value){ |
|
95 | + public function setDebug($value) { |
|
96 | 96 | return $this->setParam("debug", $value); |
97 | 97 | } |
98 | 98 | |
99 | - public function setVerbose($value){ |
|
99 | + public function setVerbose($value) { |
|
100 | 100 | return $this->setParam("verbose", $value); |
101 | 101 | } |
102 | 102 |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | public function getParam($key) { |
41 | 41 | $value=null; |
42 | - if (array_key_exists($key, $this->params)) |
|
43 | - $value=$this->params [$key]; |
|
42 | + if (array_key_exists($key, $this->params)) { |
|
43 | + $value=$this->params [$key]; |
|
44 | + } |
|
44 | 45 | return $value; |
45 | 46 | } |
46 | 47 | |
@@ -49,16 +50,18 @@ discard block |
||
49 | 50 | } |
50 | 51 | |
51 | 52 | public function compile(JsUtils $js=NULL) { |
52 | - if ($js==NULL) |
|
53 | - $js=$this->js; |
|
53 | + if ($js==NULL) { |
|
54 | + $js=$this->js; |
|
55 | + } |
|
54 | 56 | $script=$this->getScript(); |
55 | 57 | $js->addToCompile($script); |
56 | 58 | } |
57 | 59 | |
58 | 60 | protected function setParamCtrl($key, $value, $typeCtrl) { |
59 | 61 | if (\is_array($typeCtrl)) { |
60 | - if (array_search($value, $typeCtrl)===false) |
|
61 | - throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
62 | + if (array_search($value, $typeCtrl)===false) { |
|
63 | + throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
64 | + } |
|
62 | 65 | } else { |
63 | 66 | if (!$typeCtrl($value)) { |
64 | 67 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key); |
@@ -71,9 +74,9 @@ discard block |
||
71 | 74 | if(\is_array($params)) { |
72 | 75 | foreach ($params as $k => $v) { |
73 | 76 | $method = "set" . ucfirst($k); |
74 | - if (method_exists($this, $method)) |
|
75 | - $this->$method($v); |
|
76 | - else { |
|
77 | + if (method_exists($this, $method)) { |
|
78 | + $this->$method($v); |
|
79 | + } else { |
|
77 | 80 | $this->setParam($k, $v); |
78 | 81 | trigger_error("`{$k}` doesn't exists!", E_USER_NOTICE); |
79 | 82 | } |