helper.php ➔ read_time()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
function post_url($slug)
4
{
5
    return route('blog.post', $slug);
6
}
7
8
function format_date($date)
9
{
10
    $date = \Carbon\Carbon::parse($date);
11
12
    if (now()->diffInDays($date) <= 23) {
13
        return $date->diffForHumans();
14
    }
15
16
    return  $date->format('F j, Y');
17
}
18
19
function read_time($content)
20
{
21
    // count words
22
    $words = str_word_count(strip_tags($content));
23
24
    // Divide by the average number of words per minute
25
    $minutes = ceil($words / 250);
26
27
    return sprintf('%d %s %s', $minutes, Str::plural('min', $minutes), 'read');
28
}
29