Completed
Push — feature/pilot_information ( 13ff1e...cc067b )
by Laurent
01:46
created
Http/Web/Controller/PilotEditController.php 3 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -4,12 +4,9 @@
 block discarded – undo
4 4
 namespace FlightLog\Http\Web\Controller;
5 5
 
6 6
 
7
-use FlightLog\Application\Damage\Command\CreateDamageCommand;
8
-use FlightLog\Application\Damage\Command\CreateDamageCommandHandler;
9 7
 use FlightLog\Application\Pilot\Command\CreateUpdatePilotInformationCommand;
10 8
 use FlightLog\Application\Pilot\Command\CreateUpdatePilotInformationCommandHandler;
11 9
 use FlightLog\Domain\Pilot\ValueObject\PilotId;
12
-use FlightLog\Http\Web\Form\DamageCreationForm;
13 10
 use FlightLog\Http\Web\Form\PilotForm;
14 11
 use FlightLog\Infrastructure\Pilot\Repository\PilotRepository;
15 12
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
 final class PilotEditController extends WebController
17 17
 {
18 18
 
19
-    public function index(){
19
+    public function index() {
20 20
         $id = $this->request->getParam('id');
21 21
 
22
-        if($id === null){
22
+        if ($id === null) {
23 23
             $this->renderHtml('<p>Paramètre ID non fournis.</p>');
24 24
             return;
25 25
         }
26 26
 
27 27
         $command = new CreateUpdatePilotInformationCommand($id);
28 28
 
29
-        if($this->getPilotRepository()->exist(PilotId::create($id))){
29
+        if ($this->getPilotRepository()->exist(PilotId::create($id))) {
30 30
             $command->fromPilot($this->getPilotRepository()->getById(PilotId::create($id)));
31 31
         }
32 32
 
@@ -36,24 +36,24 @@  discard block
 block discarded – undo
36 36
         $user = new \User($this->db);
37 37
         $user->fetch($id);
38 38
 
39
-        if($this->request->isPost()){
39
+        if ($this->request->isPost()) {
40 40
             $form->setData($this->request->getPostParameters());
41 41
 
42
-            if(!$form->validate()){
42
+            if (!$form->validate()) {
43 43
                 return $this->render('pilot/edit.phtml', [
44 44
                     'form' => $form,
45 45
                 ]);
46 46
             }
47 47
 
48
-            try{
48
+            try {
49 49
                 $this->handle($form->getObject());
50
-            }catch(\Exception $e){
50
+            } catch (\Exception $e) {
51 51
                 print $e->getMessage();
52 52
                 dol_syslog($e->getMessage(), LOG_ERR);
53 53
             }
54 54
 
55 55
 
56
-            return $this->redirect($_SERVER["PHP_SELF"].'?id='.$id.'&r=edit_pilot');
56
+            return $this->redirect($_SERVER["PHP_SELF"] . '?id=' . $id . '&r=edit_pilot');
57 57
         }
58 58
 
59 59
         return $this->render('pilot/edit.phtml', [
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     /**
76 76
      * @return CreateUpdatePilotInformationCommandHandler()
77 77
      */
78
-    private function getHandler(){
78
+    private function getHandler() {
79 79
         return new CreateUpdatePilotInformationCommandHandler($this->getPilotRepository());
80 80
     }
81 81
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 
49 49
             try{
50 50
                 $this->handle($form->getObject());
51
-            }catch(\Exception $e){
51
+            } catch(\Exception $e){
52 52
                 print $e->getMessage();
53 53
                 dol_syslog($e->getMessage(), LOG_ERR);
54 54
             }
Please login to merge, or discard this patch.
Http/Web/Form/PilotForm.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
     }
76 76
 
77 77
     /**
78
-     * @return CreateUpdatePilotInformationCommand|\stdClass|null
78
+     * @return CreateUpdatePilotInformationCommand
79 79
      */
80 80
     public function getObject()
81 81
     {
Please login to merge, or discard this patch.
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@  discard block
 block discarded – undo
4 4
 namespace FlightLog\Http\Web\Form;
5 5
 
6 6
 
7
-use FlightLog\Application\Damage\Command\CreateDamageCommand;
8 7
 use FlightLog\Application\Pilot\Command\CreateUpdatePilotInformationCommand;
9 8
 use flightlog\form\Csrf;
10 9
 use flightlog\form\Form;
@@ -13,8 +12,6 @@  discard block
 block discarded – undo
13 12
 use flightlog\form\Input;
14 13
 use flightlog\form\InputCheckBox;
15 14
 use flightlog\form\InputDate;
16
-use flightlog\form\Number;
17
-use flightlog\form\UserSelect;
18 15
 
19 16
 final class PilotForm extends Form
20 17
 {
Please login to merge, or discard this patch.
Http/Web/Controller/PilotListController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 final class PilotListController extends WebController
15 15
 {
16 16
 
17
-    public function index(){
17
+    public function index() {
18 18
 
19 19
         $members = $this->getPilotRepository()->query();
20 20
 
Please login to merge, or discard this patch.
class/Common/ValueObject/Id.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      *
25 25
      * @return Id|static
26 26
      */
27
-    public static function create($id){
27
+    public static function create($id) {
28 28
         return new self($id);
29 29
     }
30 30
 
Please login to merge, or discard this patch.
class/Pilot/Pilot.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -526,7 +526,7 @@
 block discarded – undo
526 526
 
527 527
     public function attributeRadioLicenceDate(RadioLicenceDate $value)
528 528
     {
529
-        $this->radioLicenceDate =  $value;
529
+        $this->radioLicenceDate = $value;
530 530
     }
531 531
 
532 532
     public function attributeLastTrainingFirstHelpDate(LastTrainingDate $value)
Please login to merge, or discard this patch.
class/Pilot/ValueObject/IsOwner.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
             return self::no();
24 24
         }
25 25
 
26
-        if (is_numeric($value) || is_int($value) || (int)$value == $value) {
26
+        if (is_numeric($value) || is_int($value) || (int) $value == $value) {
27 27
             return new self($value == 1);
28 28
         }
29 29
 
Please login to merge, or discard this patch.
flightlog.inc.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -172,13 +172,13 @@
 block discarded – undo
172 172
                 continue;
173 173
             }
174 174
 
175
-            if($match == ".." || $match == "." || substr($match, 0,1) === '.'){
175
+            if ($match == ".." || $match == "." || substr($match, 0, 1) === '.') {
176 176
                 continue;
177 177
             }
178 178
 
179 179
             $element = $root . DIRECTORY_SEPARATOR . $match;
180 180
 
181
-            if(substr_count($element, '/', 3) >= 1){
181
+            if (substr_count($element, '/', 3) >= 1) {
182 182
                 scan($element);
183 183
             }
184 184
 
Please login to merge, or discard this patch.
Form/InputCheckBox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
         parent::__construct($name, FormElementInterface::TYPE_CHECKBOX, $options);
17 17
     }
18 18
 
19
-    public function checkedValue(){
19
+    public function checkedValue() {
20 20
         return 1;
21 21
     }
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
Infrastructure/Common/Repository/AbstractDomainRepository.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function __construct(\DoliDB $db, $tableName)
24 24
     {
25 25
         $this->db = $db;
26
-        $this->tableName = strpos($tableName, MAIN_DB_PREFIX) === 0 ? $tableName : MAIN_DB_PREFIX.$tableName;
26
+        $this->tableName = strpos($tableName, MAIN_DB_PREFIX) === 0 ? $tableName : MAIN_DB_PREFIX . $tableName;
27 27
     }
28 28
 
29 29
     /**
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @throws \Exception
35 35
      */
36
-    protected function write(array $elements){
36
+    protected function write(array $elements) {
37 37
         $columns = join(',', array_keys($elements));
38 38
         $values = join(',', array_map([$this, 'escape'], array_values($elements)));
39 39
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             $lasterror = $this->db->lasterror();
45 45
             dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR);
46 46
             $this->db->rollback();
47
-            throw new \Exception("Repository error - ".$lasterror);
47
+            throw new \Exception("Repository error - " . $lasterror);
48 48
         }
49 49
 
50 50
         $id = $this->db->last_insert_id($this->tableName);
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return int|string|null
59 59
      */
60
-    private function escape($value){
61
-        if(is_null($value)){
60
+    private function escape($value) {
61
+        if (is_null($value)) {
62 62
             return 'NULL';
63 63
         }
64 64
 
65
-        if(is_bool($value)){
66
-            return (int)$value;
65
+        if (is_bool($value)) {
66
+            return (int) $value;
67 67
         }
68 68
 
69
-        return is_string($value) ? "'".$this->db->escape($value)."'" : $value ;
69
+        return is_string($value) ? "'" . $this->db->escape($value) . "'" : $value;
70 70
     }
71 71
 
72 72
     /**
@@ -79,18 +79,18 @@  discard block
 block discarded – undo
79 79
     {
80 80
         $sqlModifications = [];
81 81
 
82
-        foreach($elements as $field => $value){
82
+        foreach ($elements as $field => $value) {
83 83
             $sqlModifications[] = sprintf('%s=%s', $field, $this->escape($value));
84 84
         }
85 85
 
86 86
         $this->db->begin();
87
-        $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE '.$idCol.' = %s ', $this->tableName, join(',',$sqlModifications), $id));
87
+        $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE ' . $idCol . ' = %s ', $this->tableName, join(',', $sqlModifications), $id));
88 88
 
89 89
         if (!$resql) {
90 90
             $lasterror = $this->db->lasterror();
91 91
             dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR);
92 92
             $this->db->rollback();
93
-            throw new \Exception("Repository error - ".$lasterror);
93
+            throw new \Exception("Repository error - " . $lasterror);
94 94
         }
95 95
 
96 96
         $this->db->commit();
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
      *
105 105
      * @return array|null
106 106
      */
107
-    protected function get($id, $idCol = 'rowid'){
108
-        $sql = sprintf('SELECT * FROM %s WHERE '.$idCol.' = %s', $this->tableName, $id );
107
+    protected function get($id, $idCol = 'rowid') {
108
+        $sql = sprintf('SELECT * FROM %s WHERE ' . $idCol . ' = %s', $this->tableName, $id);
109 109
 
110 110
         $resql = $this->db->query($sql);
111 111
         if (!$resql) {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             return null;
118 118
         }
119 119
 
120
-        for($i = 0; $i < $num ; $i++) {
120
+        for ($i = 0; $i < $num; $i++) {
121 121
             return $this->db->fetch_array($resql);
122 122
         }
123 123
 
Please login to merge, or discard this patch.