mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Migrate dev-specific configuration to env vars via .env file
This commit is contained in:
@@ -4,17 +4,31 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Matomo;
|
||||
|
||||
class MatomoOptions
|
||||
use Shlinkio\Shlink\Core\Config\EnvVars;
|
||||
|
||||
final readonly class MatomoOptions
|
||||
{
|
||||
/**
|
||||
* @param numeric-string|int|null $siteId
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly bool $enabled = false,
|
||||
public readonly ?string $baseUrl = null,
|
||||
/** @var numeric-string|int|null */
|
||||
private readonly string|int|null $siteId = null,
|
||||
public readonly ?string $apiToken = null,
|
||||
public bool $enabled = false,
|
||||
public ?string $baseUrl = null,
|
||||
private string|int|null $siteId = null,
|
||||
public ?string $apiToken = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public static function fromEnv(): self
|
||||
{
|
||||
return new self(
|
||||
enabled: (bool) EnvVars::MATOMO_ENABLED->loadFromEnv(),
|
||||
baseUrl: EnvVars::MATOMO_BASE_URL->loadFromEnv(),
|
||||
siteId: EnvVars::MATOMO_SITE_ID->loadFromEnv(),
|
||||
apiToken: EnvVars::MATOMO_API_TOKEN->loadFromEnv(),
|
||||
);
|
||||
}
|
||||
|
||||
public function siteId(): ?int
|
||||
{
|
||||
if ($this->siteId === null) {
|
||||
|
||||
Reference in New Issue
Block a user