Code Duplication    Length = 23-23 lines in 2 locations

app/src/Comment/CommentsInSession.php 1 location

@@ 10-32 (lines=23) @@
7
class CommentsInSession extends \Phpmvc\Comment\CommentsInSession
8
{
9
10
    private function humanTiming($time)
11
    {
12
13
        $time = time() - $time; // to get the time since that moment
14
        $time = ($time<1)? 1 : $time;
15
        $tokens = array (
16
            31536000 => 'år',
17
            2592000 => 'månader',
18
            604800 => 'veckor',
19
            86400 => 'dagar',
20
            3600 => 'timmar',
21
            60 => 'minuter',
22
            1 => 'sekunder'
23
        );
24
25
        foreach ($tokens as $unit => $text) {
26
            if ($time < $unit) {
27
                continue;
28
            }
29
            $numberOfUnits = floor($time / $unit);
30
            return $numberOfUnits.' '.$text.(($numberOfUnits>1)?' ':'');
31
        }
32
    }
33
34
    /**
35
     * Get either a Gravatar URL or complete image tag for a specified email address.

app/src/CommentDb/CommentsInDb.php 1 location

@@ 67-89 (lines=23) @@
64
        ]);
65
66
    }
67
    private function humanTiming($time)
68
    {
69
70
        $time = time() - $time; // to get the time since that moment
71
        $time = ($time<1)? 1 : $time;
72
        $tokens = array (
73
            31536000 => 'år',
74
            2592000 => 'månader',
75
            604800 => 'veckor',
76
            86400 => 'dagar',
77
            3600 => 'timmar',
78
            60 => 'minuter',
79
            1 => 'sekunder'
80
        );
81
82
        foreach ($tokens as $unit => $text) {
83
            if ($time < $unit) {
84
                continue;
85
            }
86
            $numberOfUnits = floor($time / $unit);
87
            return $numberOfUnits.' '.$text.(($numberOfUnits>1)?' ':'');
88
        }
89
    }
90
91
    /**
92
     * Get either a Gravatar URL or complete image tag for a specified email address.