toDateTime()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 1
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
/*
10
 * stores user local timezone in session
11
 * 
12
 */
13
14
function storeUserTimeZone($tzName) {
15
    Session::put('tzName', $tzName);
16
}
17
18
/**
19
 * 
20
 * @return fomratedDateTime 
0 ignored issues
show
Bug introduced by
The type fomratedDateTime was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
 * @param string $timeStamp Timestamp from db
22
 * 
23
 */
24
function toDateTime($timesTamp) {
25
    
26
    $tzName = Session::get('tzName');
27
    if($tzName!='Asia/Kolkata'){
28
    $tz = new DateTimeZone(trim($tzName));
29
   
30
    $date = new DateTime($timesTamp);
31
     $date->setTimezone($tz);
32
    $dateTime=$date->format('F jS, Y h:m:s A');
33
    return $dateTime;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $dateTime returns the type string which is incompatible with the documented return type fomratedDateTime.
Loading history...
34
    }
35
    else{
36
      $date = new DateTime($timesTamp);
37
    $dateTime= $date->format('F jS, Y h:m:s A');
38
    return $dateTime;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $dateTime returns the type string which is incompatible with the documented return type fomratedDateTime.
Loading history...
39
    }
40
    
41
}
42
43
44
/**
45
46
 * @function generates a unique ID
47
 * @return string unique id
48
 */
49
50
function generateId(){
51
    $date = date_create();
52
    $id=md5(date_timestamp_get($date));
0 ignored issues
show
Bug introduced by
It seems like $date can also be of type false; however, parameter $object of date_timestamp_get() does only seem to accept DateTimeInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

52
    $id=md5(date_timestamp_get(/** @scrutinizer ignore-type */ $date));
Loading history...
53
    return $id;
54
    
55
}