UtilityService::ConvertTimeForClientDisplay()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 13
rs 9.9666
c 0
b 0
f 0
cc 4
nc 5
nop 1
1
<?php
2
namespace PhpDraft\Domain\Services;
3
4
use Silex\Application;
5
6
class UtilityService {
7
  private $app;
8
9
  public function __construct(Application $app) {
10
    $this->app = $app;
11
  }
12
13
  public function ConvertTimeForClientDisplay($time_value) {
14
    if (empty($time_value)) {
15
      return null;
16
    }
17
18
    $time_value_length = strlen($time_value);
19
    $supposed_utc_index = $time_value_length > 3 ? $time_value_length - 3 : 0;
20
    $utc_index = strstr($time_value, "UTC");
21
22
    if ($utc_index == $supposed_utc_index) {
23
      return $time_value;
24
    } else {
25
      return $time_value . " UTC";
26
    }
27
  }
28
}