GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch master (9f36d7)
by w3l
02:08
created

Time::time_elapsed()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 25
c 1
b 0
f 0
rs 8.439
cc 5
eloc 18
nc 8
nop 1
1
<?php
2
namespace Holt45;
3
trait Time {
4
	
5
	/**
6
	 * Convert timestamp to HTTP-date (RFC2616)
7
	 *
8
	 * For use in "Last-Modified" headers.
9
	 *
10
	 * @param string $timestamp
11
	 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be null|string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
12
	 */
13
	public static function timestamp_to_http_date($timestamp) {
14
		if($timestamp == NULL) { return NULL; }
15
		return gmdate("D, d M Y H:i:s T", strtotime($timestamp));
16
	}
17
	
18
	/**
19
	 * Convert timestamp to "x unit"
20
	 *
21
	 * @param string $timestamp
22
	 * @return string
23
	 */
24
	public static function time_elapsed($timestamp) {
25
		$seconds = max((time() - strtotime($timestamp)),0);
26
		
27
		if($seconds < 60) {
28
			$number = $seconds;
29
			$text = "second";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
30
		} elseif($seconds < (60 * 60)) {
31
			$number = $seconds / 60;
32
			$text = "minute";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
33
		} elseif($seconds < (60 * 60 * 24)) {
34
			$number = $seconds / (60 * 60);
35
			$text = "hour";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
36
		} else {
37
			$number = $seconds / (60 * 60 * 24);
38
			$text = "day";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
39
		}
40
41
		$number = floor($number);
42
		
43
		if($number > 1) {
44
		$text.="s";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
45
		}
46
		
47
		return "$number $text";
48
	}
49
	
50
}