forked from liip/LiipImagineBundle
/
SymfonyFramework.php
70 lines (62 loc) · 1.87 KB
/
SymfonyFramework.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Liip\ImagineBundle\Utility\Framework;
use Symfony\Component\HttpKernel\Kernel;
class SymfonyFramework
{
/**
* @return bool
*/
public static function hasDirectContainerBuilderLogging(): bool
{
return method_exists('\Symfony\Component\DependencyInjection\ContainerBuilder', 'log');
}
/**
* @return string
*/
public static function getContainerResolvableRootWebPath(): string
{
return sprintf('%%kernel.project_dir%%/%s', self::isKernelLessThan(4) ? 'web' : 'public');
}
/**
* @param int $major
* @param int|null $minor
* @param int|null $patch
*
* @return bool
*/
public static function isKernelGreaterThanOrEqualTo(int $major, int $minor = null, int $patch = null): bool
{
return static::kernelVersionCompare('>=', $major, $minor, $patch);
}
/**
* @param int $major
* @param int|null $minor
* @param int|null $patch
*
* @return bool
*/
public static function isKernelLessThan(int $major, int $minor = null, int $patch = null): bool
{
return static::kernelVersionCompare('<', $major, $minor, $patch);
}
/**
* @param string $operator
* @param int $major
* @param int|null $minor
* @param int|null $patch
*
* @return bool
*/
private static function kernelVersionCompare(string $operator, int $major, int $minor = null, int $patch = null): bool
{
return version_compare(Kernel::VERSION_ID, sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator);
}
}