Skip to content

Commit 62acf64

Browse files
committed
style: various code style fixes
1 parent 6a0e19a commit 62acf64

8 files changed

Lines changed: 22 additions & 20 deletions

File tree

src/AbstractImpact.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737

3838
abstract class AbstractImpact extends CommonDBChild
3939
{
40+
public static $itemtype = 'itemtype';
41+
public static $items_id = 'items_id';
42+
4043
public static $rightname = 'carbon:report';
4144

4245
public function rawSearchOptions()
@@ -117,8 +120,8 @@ public function rawSearchOptions()
117120
public function getHumanReadableImpact(string $field): string
118121
{
119122
return Toolbox::getHumanReadableValue(
120-
$this->fields[$field],
121-
Type::getImpactUnit($field)
123+
$this->fields[$field],
124+
Type::getImpactUnit($field)
122125
);
123126
}
124-
}
127+
}

src/Dashboard/DemoProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,10 @@ public static function getImpactOfEmbodiedAndUsageCriteria(string $impact_type,
462462
$crit['itemtype'] = array_intersect($crit['itemtype'], PLUGIN_CARBON_TYPES);
463463
}
464464

465-
$value = self::$impact_values[$impact_type][0] ?? 0 + self::$impact_values[$impact_type][1] ?? 0;
466-
if ($value === null) {
465+
if (self::$impact_values[$impact_type][0] === null && self::$impact_values[$impact_type][1] === null) {
467466
$value = 'N/A';
468467
} else {
468+
$value = (self::$impact_values[$impact_type][0] ?? 0) + (self::$impact_values[$impact_type][1] ?? 0);
469469
$value = Toolbox::getHumanReadableValue(
470470
$value,
471471
Type::getImpactUnit($impact_type)

src/EmbodiedImpact.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
use DBmysql;
3737
use DBmysqlIterator;
3838
use Glpi\DBAL\QuerySubQuery;
39-
use GlpiPlugin\Carbon\Impact\Type;
4039

4140
/**
4241
* Embodied impact of assets

src/Impact/Embodied/AbstractEmbodiedImpact.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ public static function getItemsToEvaluate(string $itemtype, array $crit = []): D
108108
/** @var DBmysql $DB */
109109
global $DB;
110110

111-
$crit[] = ['OR' => [
112-
EmbodiedImpact::getTableField('id') => null,
113-
EmbodiedImpact::getTableField('recalculate') => 1,
114-
]];
111+
$crit[] = [
112+
'OR' => [
113+
EmbodiedImpact::getTableField('id') => null,
114+
EmbodiedImpact::getTableField('recalculate') => 1,
115+
]
116+
];
115117
$iterator = $DB->request(self::getEvaluableQuery($itemtype, $crit, false));
116118

117119
return $iterator;

src/Impact/Usage/AbstractUsageImpact.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ public function getItemsToEvaluate(array $crit = []): DBmysqlIterator
116116
throw new \LogicException('Itemtype does not inherits from ' . CommonDBTM::class);
117117
}
118118

119-
$crit[] = ['OR' => [
120-
UsageImpact::getTableField('id') => null,
121-
UsageImpact::getTableField('recalculate') => 1,
122-
]];
119+
$crit[] = [
120+
'OR' => [
121+
UsageImpact::getTableField('id') => null,
122+
UsageImpact::getTableField('recalculate') => 1,
123+
]
124+
];
123125
$crit[UsageImpact::getTableField('id')] = null;
124126
$iterator = $DB->request($this->getEvaluableQuery($crit, false));
125127

src/UsageImpact.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636

3737
class UsageImpact extends AbstractImpact
3838
{
39-
public static $itemtype = 'itemtype';
40-
public static $items_id = 'items_id';
41-
4239
public static function getTypeName($nb = 0)
4340
{
4441
return _n("Usage impact", "Usage impacts", $nb, 'carbon');

templates/environmentalimpact-item.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
{{ label }}
4848
</div>
4949
<div class="col-xxl-5">
50-
<span id="embodied_{{criteria}}_tip">
50+
<span id="embodied_{{ criteria }}_tip">
5151
{{ usage_impact.getHumanReadableImpact(criteria)|raw }}
5252
{# <i class="fa-solid fa-circle-info"></i> #}
5353
</span>
@@ -101,7 +101,7 @@
101101
{{ label }}
102102
</div>
103103
<div class="col-xxl-5">
104-
<span id="embodied_{{criteria}}_tip">
104+
<span id="embodied_{{ criteria }}_tip">
105105
{{ embodied_impact.getHumanReadableImpact(criteria)|raw }}
106106
{# <i class="fa-solid fa-circle-info"></i> #}
107107
</span>

tests/src/Impact/Embodied/AbstractEmbodiedImpactTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public function testGetItemsToEvaluate()
100100
$asset::getTableField('id') => $asset->getID(),
101101
]);
102102
$this->assertEquals(1, $iterator->count());
103-
104103
}
105104

106105
public function testGetEvaluableQuery()

0 commit comments

Comments
 (0)