Completed
Push — feature/graph_stat_flight ( ed413f )
by Laurent
01:27
created
class/card/TabCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
      * @return array
54 54
      */
55 55
     public function toArray() {
56
-        return array_map(function(Tab $tab){
56
+        return array_map(function(Tab $tab) {
57 57
             return $tab->toArray();
58 58
         }, $this->tabs);
59 59
     }
Please login to merge, or discard this patch.
query/BillableFlightQueryHandler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
         //Total damages
147 147
         $damages = $this->pilotDamageQueryRepository->query($query->getFiscalYear());
148
-        foreach($damages as $currentDamage){
148
+        foreach ($damages as $currentDamage) {
149 149
 
150 150
             //Pilot doesn't exist
151 151
             if (!isset($pilots[$currentDamage->getAuthorId()])) {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             );
159 159
 
160 160
             // The damage is already invoiced. So not take into account.
161
-            if($currentDamage->isInvoiced()){
161
+            if ($currentDamage->isInvoiced()) {
162 162
                 $pilots[$currentDamage->getAuthorId()] = $pilots[$currentDamage->getAuthorId()]->addCount(
163 163
                     new FlightTypeCount('invoiced_damage', $currentDamage->getAmount(), -1)
164 164
                 );
Please login to merge, or discard this patch.
readFlights.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     print '<td>' . $pilot->getCountForType('orga_T6')->getCount() . '</td>';
231 231
     print '<td>' . $pilot->getCountForType('orga_T6')->getCost()->getValue() . '</td>';
232 232
 
233
-    print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0?'text-muted':'text-bold'). $pilot->getFlightBonus()->getValue() . ' pts</td>';
233
+    print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0 ? 'text-muted' : 'text-bold') . $pilot->getFlightBonus()->getValue() . ' pts</td>';
234 234
 
235 235
     print '<td>' . $pilot->getCountForType('3')->getCount() . '</td>';
236 236
     print '<td>' . price($pilot->getCountForType('3')->getCost()->getValue()) . '€</td>';
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
     print '<td>' . price($pilot->getCountForType('damage')->getCost()->getValue()) . '€</td>';
250 250
     print '<td>' . price($pilot->getCountForType('invoiced_damage')->getCost()->getValue()) . '€</td>';
251 251
 
252
-    print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0?'text-muted':'text-bold'). price($pilot->getFlightsCost()->getValue()) . '€ </td>';
253
-    print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero())?'text-bold':'text-muted'). price($pilot->getTotalBill()->getValue()) . '€</td>';
252
+    print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0 ? 'text-muted' : 'text-bold') . price($pilot->getFlightsCost()->getValue()) . '€ </td>';
253
+    print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero()) ? 'text-bold' : 'text-muted') . price($pilot->getTotalBill()->getValue()) . '€</td>';
254 254
     print '</tr>';
255 255
 }
256 256
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 print '<td>' . $totalT3 . '</td>';
276 276
 print '<td></td>';
277 277
 
278
-print '<td>' . $totalT4. '</td>';
278
+print '<td>' . $totalT4 . '</td>';
279 279
 print '<td></td>';
280 280
 
281 281
 print '<td>' . $totalT5 . '</td>';
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 //table km
305 305
 $tauxRemb = isset($conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM) ? $conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM : 0;
306 306
 $year = GETPOST("year", 'int');
307
-if(empty($year)){
307
+if (empty($year)) {
308 308
     $year = date('Y');
309 309
 }
310 310
 
Please login to merge, or discard this patch.
Infrastructure/Damage/Query/Repository/GetPilotDamagesQueryRepository.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,16 +35,16 @@
 block discarded – undo
35 35
     public function query($year)
36 36
     {
37 37
         $sql = 'SELECT damage.amount as amount, damage.billed as billed, damage.author_id as author, author.firstname as author_name';
38
-        $sql.=' FROM '.MAIN_DB_PREFIX.'bbc_flight_damages as damage';
39
-        $sql.=' INNER JOIN '.MAIN_DB_PREFIX.'bbc_vols as flight ON flight.rowid = damage.flight_id';
40
-        $sql.=' INNER JOIN '.MAIN_DB_PREFIX.'user as author ON author.rowid = damage.author_id';
41
-        $sql.=' WHERE YEAR(flight.date) = '.$this->db->escape($year);
38
+        $sql .= ' FROM ' . MAIN_DB_PREFIX . 'bbc_flight_damages as damage';
39
+        $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'bbc_vols as flight ON flight.rowid = damage.flight_id';
40
+        $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'user as author ON author.rowid = damage.author_id';
41
+        $sql .= ' WHERE YEAR(flight.date) = ' . $this->db->escape($year);
42 42
 
43 43
         $resql = $this->db->query($sql);
44 44
         if ($resql) {
45 45
             $num = $this->db->num_rows($resql);
46 46
             if ($num) {
47
-                for($i = 0; $i < $num ; $i++) {
47
+                for ($i = 0; $i < $num; $i++) {
48 48
                     $properties = $this->db->fetch_array($resql);
49 49
                     $damage = TotalDamage::fromArray($properties);
50 50
                     yield $damage;
Please login to merge, or discard this patch.
Application/Damage/Command/InvoiceDamageCommandHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      *
29 29
      * @throws \Exception
30 30
      */
31
-    public function __invoke(InvoiceDamageCommand $command){
31
+    public function __invoke(InvoiceDamageCommand $command) {
32 32
         $damage = $this->damageRepository->getById(DamageId::create($command->getDamageId()));
33 33
         $damage = $damage->invoice();
34 34
         $this->damageRepository->save($damage);
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 rowid = %s ', $this->tableName, join(',',$sqlModifications), $id));
87
+        $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE rowid = %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();
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * @return array|null
105 105
      */
106
-    protected function get($id){
107
-        $sql = sprintf('SELECT * FROM %s WHERE rowid = %s', $this->tableName, $id );
106
+    protected function get($id) {
107
+        $sql = sprintf('SELECT * FROM %s WHERE rowid = %s', $this->tableName, $id);
108 108
 
109 109
         $resql = $this->db->query($sql);
110 110
         if (!$resql) {
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             return null;
117 117
         }
118 118
 
119
-        for($i = 0; $i < $num ; $i++) {
119
+        for ($i = 0; $i < $num; $i++) {
120 120
             return $this->db->fetch_array($resql);
121 121
         }
122 122
 
Please login to merge, or discard this patch.
Application/Damage/Command/CreateDamageCommand.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -27,6 +27,9 @@
 block discarded – undo
27 27
      */
28 28
     private $billId;
29 29
 
30
+    /**
31
+     * @param integer $authorId
32
+     */
30 33
     public function __construct($authorId)
31 34
     {
32 35
         $this->authorId = $authorId;
Please login to merge, or discard this patch.
Infrastructure/Common/Routes/Route.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,6 @@
 block discarded – undo
61 61
     }
62 62
 
63 63
     /**
64
-     * @param string $action
65 64
      *
66 65
      * @return bool
67 66
      */
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,6 @@
 block discarded – undo
4 4
 namespace FlightLog\Infrastructure\Common\Routes;
5 5
 
6 6
 
7
-use FlightLog\Http\Web\Controller\WebController;
8
-
9 7
 final class Route
10 8
 {
11 9
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
      *
66 66
      * @return bool
67 67
      */
68
-    public function match($route){
68
+    public function match($route) {
69 69
         return $this->name === $route;
70 70
     }
71 71
 
Please login to merge, or discard this patch.
Application/Damage/Command/CreateDamageCommandHandler.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function __invoke(CreateDamageCommand $command)
42 42
     {
43 43
         $damage = FlightDamage::waiting(new DamageAmount($command->getAmount()), AuthorId::create($command->getAuthorId()));
44
-        if(null !== $command->getFlightId()){
44
+        if (null !== $command->getFlightId()) {
45 45
             $damage = FlightDamage::damage(FlightId::create($command->getFlightId()), new DamageAmount($command->getAmount()), AuthorId::create($command->getAuthorId()));
46 46
         }
47 47
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     private function linkSupplierInvoice($damageId, $invoiceId)
61 61
     {
62
-        if($invoiceId <= 0){
62
+        if ($invoiceId <= 0) {
63 63
             return;
64 64
         }
65 65
 
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
      * @param int $targetId
81 81
      * @param string $targetType
82 82
      */
83
-    private function insertLinks($damageId, $targetId, $targetType){
84
-        $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
83
+    private function insertLinks($damageId, $targetId, $targetType) {
84
+        $sql = "INSERT INTO " . MAIN_DB_PREFIX . "element_element (";
85 85
         $sql .= "fk_source";
86 86
         $sql .= ", sourcetype";
87 87
         $sql .= ", fk_target";
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
         $sql .= ") VALUES (";
90 90
         $sql .= $damageId;
91 91
         $sql .= ", 'flightlog_damage'";
92
-        $sql .= ", ".$targetId;
93
-        $sql .= ", '".$targetType."'";
92
+        $sql .= ", " . $targetId;
93
+        $sql .= ", '" . $targetType . "'";
94 94
         $sql .= ")";
95 95
 
96 96
         if ($this->db->query($sql))
Please login to merge, or discard this patch.