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.

Issues (92)

src/Traits/TimeHelperTraits.php (2 issues)

1
<?php
2
3
namespace Raystech\StarterKit\Traits;
4
5
use Carbon\Carbon;
6
7
trait TimeHelperTraits
8
{
9
10
  public function ago()
11
  {
12
    if(!$this->created_at) {
13
      return 'n/a';
14
    }
15
    $time = Carbon::parse($this->created_at);
16
    $diff = $time->diffInSeconds(Carbon::now());
17
    if ($diff == 0) {
18
      return 'Just now';
19
    }
20
    $intervals = array(
21
      1                => array('year', 31556926),
22
      $diff < 31556926 => array('month', 2628000),
23
      $diff < 2629744  => array('week', 604800),
24
      $diff < 604800   => array('day', 86400),
25
      $diff < 86400    => array('hr', 3600),
26
      $diff < 3600     => array('min', 60),
27
      $diff < 60       => array('second', 1),
28
    );
29
    $value = floor($diff / $intervals[1][1]);
30
    $ago = $value.' '.$intervals[1][0].($value > 1 ? 's' : '');
31
32
    // $ago  = $value . ' ' . $intervals[1][0];
33
    $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
0 ignored issues
show
The assignment to $days is dead and can be removed.
Loading history...
34
    $day  = $time->format('d');
0 ignored issues
show
The assignment to $day is dead and can be removed.
Loading history...
35
    // return $intervals[1][0];
36
    if ($ago == '1 day') {
37
      return 'Yesterday at ' . $time->format('H:i');
38
    } elseif ($value <= 59 && $intervals[1][0] == 'second' || $intervals[1][0] == 'min' || $intervals[1][0] == 'hr') {
39
      return $ago;
40
    } elseif($time->year == Carbon::now()->year) {
41
      return $time->format('M d') . ' at ' . $time->format('H:i');
42
    } else {
43
      return $time->format('M d, Y') . ' at ' . $time->format('H:i');
44
    }
45
  }
46
}