Issues (97)

app/Logic/helpers.php (2 issues)

1
<?php
2
3
/**
4
 * Return sizes readable by humans.
5
 */
6
function human_filesize($bytes, $decimals = 2)
7
{
8
    $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB'];
9
    $factor = floor((strlen($bytes) - 1) / 3);
10
11
    return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)).@$size[$factor];
12
}
13
14
/**
15
 * Is the mime type an image.
16
 */
17
function is_image($mimeType)
18
{
19
    return starts_with($mimeType, 'image/');
0 ignored issues
show
Deprecated Code introduced by
The function starts_with() has been deprecated: Str::startsWith() should be used directly instead. Will be removed in Laravel 6.0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

19
    return /** @scrutinizer ignore-deprecated */ starts_with($mimeType, 'image/');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
20
}
21
22
/**
23
 * Return "checked" if true.
24
 */
25
function checked($value)
26
{
27
    return $value ? 'checked' : '';
28
}
29
30
/**
31
 * Return img url for headers.
32
 */
33
function post_image($value = null)
34
{
35
    if (empty($value)) {
36
        $value = config('blog.post_image');
37
    }
38
    if (!starts_with($value, 'http') && $value[0] !== '/') {
0 ignored issues
show
Deprecated Code introduced by
The function starts_with() has been deprecated: Str::startsWith() should be used directly instead. Will be removed in Laravel 6.0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

38
    if (!/** @scrutinizer ignore-deprecated */ starts_with($value, 'http') && $value[0] !== '/') {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
39
        $value = config('blog.uploads.webpath').'/'.$value;
40
    }
41
42
    return $value;
43
}
44