Spaces:
No application file
No application file
File size: 4,477 Bytes
d2897cd |
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
<?php
declare(strict_types=1);
namespace Mautic\CoreBundle\Release;
final class Metadata implements \JsonSerializable
{
private string $version;
private int $majorVersion;
private int $minorVersion;
private int $patchVersion;
private string $extraVersion;
private string $stability;
private string $minSupportedPHPVersion;
private string $maxSupportedPHPVersion;
/**
* We use this property to show a warning message on the dashboard
* if the user has a PHP version that is lower than the given version.
* Users are warned that their PHP version won't be supported by future
* Mautic versions anymore.
*/
private string $showPHPVersionWarningIfUnder;
private string $minSupportedMauticVersion;
private string $announcementUrl;
private string $minSupportedMySqlVersion;
private string $minSupportedMariaDbVersion;
public function __construct(array $metadata)
{
$this->version = $metadata['version'];
$this->stability = $metadata['stability'];
$this->minSupportedPHPVersion = $metadata['minimum_php_version'];
$this->maxSupportedPHPVersion = $metadata['maximum_php_version'];
$this->showPHPVersionWarningIfUnder = $metadata['show_php_version_warning_if_under'] ?? '';
$this->minSupportedMauticVersion = $metadata['minimum_mautic_version'];
$this->announcementUrl = $metadata['announcement_url'];
$this->minSupportedMySqlVersion = $metadata['minimum_mysql_version'] ?? '';
$this->minSupportedMariaDbVersion = $metadata['minimum_mariadb_version'] ?? '';
preg_match('#^(\d+)\.(\d+)\.(\d+)[\. \-]?(.*+)?$#', $this->version, $match);
$this->majorVersion = (int) $match[1];
$this->minorVersion = (int) $match[2];
$this->patchVersion = (int) $match[3];
$this->extraVersion = $match[4] ?? '';
}
public function getVersion(): string
{
return $this->version;
}
public function getMajorVersion(): int
{
return $this->majorVersion;
}
public function getMinorVersion(): int
{
return $this->minorVersion;
}
public function getPatchVersion(): int
{
return $this->patchVersion;
}
public function getExtraVersion(): string
{
return $this->extraVersion;
}
public function getStability(): string
{
return $this->stability;
}
public function getMinSupportedPHPVersion(): string
{
return $this->minSupportedPHPVersion;
}
public function getMaxSupportedPHPVersion(): string
{
return $this->maxSupportedPHPVersion;
}
/**
* We use this property to show a warning message on the dashboard
* if the user has a PHP version that is lower than the given version.
* Users are warned that their PHP version won't be supported by future
* Mautic versions anymore.
*/
public function getShowPHPVersionWarningIfUnder(): string
{
return $this->showPHPVersionWarningIfUnder;
}
public function getMinSupportedMauticVersion(): string
{
return $this->minSupportedMauticVersion;
}
public function getAnnouncementUrl(): string
{
return $this->announcementUrl;
}
public function getMinSupportedMySqlVersion(): string
{
return $this->minSupportedMySqlVersion;
}
public function getMinSupportedMariaDbVersion(): string
{
return $this->minSupportedMariaDbVersion;
}
/**
* @return array<string, int|string>
*/
public function jsonSerialize(): array
{
return [
'version' => $this->version,
'stability' => $this->stability,
'minimum_php_version' => $this->minSupportedPHPVersion,
'maximum_php_version' => $this->maxSupportedPHPVersion,
'show_php_version_warning_if_under' => $this->showPHPVersionWarningIfUnder,
'minimum_mautic_version' => $this->minSupportedMauticVersion,
'announcement_url' => $this->announcementUrl,
'minimum_mysql_version' => $this->minSupportedMySqlVersion,
'minimum_mariadb_version' => $this->minSupportedMariaDbVersion,
];
}
}
|