for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Enjoys\AssetsCollector;
class Helpers
{
public static function getHttpScheme(): string
$scheme = 'http';
if (isset($_SERVER['HTTP_SCHEME'])) {
return $_SERVER['HTTP_SCHEME'];
}
if (isset($_SERVER['HTTPS']) && \strtolower($_SERVER['HTTPS']) != 'off') {
return 'https';
if (isset($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT']) {
return $scheme;
/**
* @param string $file
* @param string $data
* @param string $mode
* @return void
*/
public static function writeFile(string $file, string $data, string $mode = 'w'): void
$f = fopen($file, $mode);
if ($f !== false) {
fwrite($f, $data);
fclose($f);
* @param string $path
* @param int $permissions
* @throws \Exception
public static function createDirectory(string $path, int $permissions = 0777): void
if (preg_match("/(\/\.+|\.+)$/i", $path)) {
throw new \Exception(
sprintf("Нельзя создать директорию: %s", $path)
);
//Clear the most recent error
error_clear_last();
if (!is_dir($path)) {
if (@mkdir($path, $permissions, true) === false) {
/** @var string[] $error */
$error = error_get_last();
sprintf("Не удалось создать директорию: %s! Причина: %s", $path, $error['message'])