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
Push — dev ( b6442a...4385af )
by w3l
06:19
created

Time::timestampToHttpDate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
namespace w3l\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 timestampToHttpDate($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(plural), like "6 minutes" or "1 day".
20
	 *
21
	 * @param string $timestamp
22
	 * @param int $limit Limit in seconds when to return nothing
0 ignored issues
show
Bug introduced by
There is no parameter named $limit. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
23
	 * @return string Formated time: "x unit(s)" or empty string
24
	 */
25
	public static function timeElapsed($timestamp) {
26
		$seconds = max((time() - strtotime($timestamp)),0);
27
		
28
		if($seconds < 60) {
29
			$number = $seconds;
30
			$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...
31
		} elseif($seconds < (60 * 60)) {
32
			$number = $seconds / 60;
33
			$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...
34
		} elseif($seconds < (60 * 60 * 24)) {
35
			$number = $seconds / (60 * 60);
36
			$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...
37
		} else {
38
			$number = $seconds / (60 * 60 * 24);
39
			$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...
40
		}
41
42
		$number = floor($number);
43
		
44
		if($number > 1) {
45
		$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...
46
		}
47
		
48
		return "$number $text";
49
	}
50
	
51
}