UtilityService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 12
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A ConvertTimeForClientDisplay() 0 13 4
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
}