SymfonyFramework::isKernelLessThan()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Utility\Framework;
13
14
use Symfony\Component\HttpKernel\Kernel;
15
16
/**
17
 * @internal
18
 */
19
final class SymfonyFramework
20
{
21
    public static function getContainerResolvableRootWebPath(): string
22
    {
23
        return sprintf('%%kernel.project_dir%%/%s', self::isKernelLessThan(4) ? 'web' : 'public');
24
    }
25
26
    public static function isKernelGreaterThanOrEqualTo(int $major, int $minor = null, int $patch = null): bool
27
    {
28
        return static::kernelVersionCompare('>=', $major, $minor, $patch);
0 ignored issues
show
Comprehensibility introduced by
Since Liip\ImagineBundle\Utili...mework\SymfonyFramework is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
29
    }
30
31
    public static function isKernelLessThan(int $major, int $minor = null, int $patch = null): bool
32
    {
33
        return static::kernelVersionCompare('<', $major, $minor, $patch);
0 ignored issues
show
Comprehensibility introduced by
Since Liip\ImagineBundle\Utili...mework\SymfonyFramework is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
34
    }
35
36
    private static function kernelVersionCompare(string $operator, int $major, int $minor = null, int $patch = null): bool
37
    {
38
        return version_compare(Kernel::VERSION_ID, sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator);
39
    }
40
}
41