Time   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A timeConversion() 0 17 5
1
<?php
2
/**
3
 * Time Class Doc Comment
4
 *
5
 * PHP version 5
6
 *
7
 * @category PHP
8
 * @package  OpenChat
9
 * @author   Ankit Jain <[email protected]>
10
 * @license  The MIT License (MIT)
11
 * @link     https://github.com/ankitjain28may/openchat
12
 */
13
namespace ChatApp;
14
15
/**
16
 * For the conversion of time
17
 *
18
 * @category PHP
19
 * @package  OpenChat
20
 * @author   Ankit Jain <[email protected]>
21
 * @license  The MIT License (MIT)
22
 * @link     https://github.com/ankitjain28may/openchat
23
 */
24
class Time
25
{
26
    /*
27
    |--------------------------------------------------------------------------
28
    | Time Class
29
    |--------------------------------------------------------------------------
30
    |
31
    | For the conversion of time.
32
    |
33
    */
34
35
    /**
36
     * Create a new class instance.
37
     *
38
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
39
     */
40
    public function __construct()
41
    {
42
        // code...
43
    }
44
45
    /**
46
     * Convert Time according to the time passes
47
     *
48
     * @param string $time To store time
49
     *
50
     * @return string $time
51
     */
52
    public function timeConversion($time)
53
    {
54
55
        if (substr($time, 4, 11) == date("d M Y", time() + 16200)) {
56
            $time = substr($time, 16, 5);
57
        } else if (substr($time, 7, 8) == date("M Y", time() + 16200)
58
            && substr($time, 4, 2) - date("d") < 7
59
        ) {
60
            $time = substr($time, 0, 3);
61
        } else if (substr($time, 11, 4) == date("Y", time() + 16200)) {
62
            $time = substr($time, 4, 6);
63
        } else {
64
            $time = substr($time, 4, 11);
65
        }
66
67
        return $time;
68
    }
69
}
70