blue-twilight/installer/helpers.php

29 lines
912 B
PHP

<?php
function ends_with($stringToCheck, $stringToFind)
{
return strlen($stringToCheck) >= strlen($stringToFind) &&
substr(strtolower($stringToCheck), strlen($stringToCheck) - strlen($stringToFind), strlen($stringToFind)) == strtolower($stringToFind);
}
/**
* A crude implementation of a .env reader to allow the installer to have overriden values from .env.install.
* @param $key
* @param null $default
*/
function env($key, $default = null)
{
$envFilePath = sprintf('%s/.env.install', dirname(__DIR__));
if (!file_exists($envFilePath))
{
return $default;
}
return \App\Helpers\MiscHelper::getEnvironmentSetting($key, $envFilePath) ?? $default;
}
function starts_with($stringToCheck, $stringToFind)
{
return strlen($stringToCheck) >= strlen($stringToFind) &&
substr(strtolower($stringToCheck), 0, strlen($stringToFind)) == strtolower($stringToFind);
}