-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f97b6b
commit 9697633
Showing
2 changed files
with
34 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* @author Eric Sizemore <[email protected]> | ||
* @package Utility | ||
* @link http://www.secondversion.com/ | ||
* @version 1.1.0 | ||
* @version 1.1.1 | ||
* @copyright (C) 2017 - 2023 Eric Sizemore | ||
* @license The MIT License (MIT) | ||
*/ | ||
|
@@ -54,7 +54,7 @@ | |
* @author Eric Sizemore <[email protected]> | ||
* @package Utility | ||
* @link http://www.secondversion.com/ | ||
* @version 1.1.0 | ||
* @version 1.1.1 | ||
* @copyright (C) 2017 - 2023 Eric Sizemore | ||
* @license The MIT License (MIT) | ||
* | ||
|
@@ -648,6 +648,11 @@ public static function lineCounter(string $directory, array $ignore = [], array | |
} | ||
|
||
$content = file($val->getPath() . DIRECTORY_SEPARATOR . $val->getFilename(), $flags); | ||
|
||
if (!$content) { | ||
continue; | ||
} | ||
/** @var array<int, string>|\Countable $content **/ | ||
$content = count($content); | ||
|
||
$lines[$val->getPath()][$val->getFilename()] = $content; | ||
|
@@ -768,9 +773,9 @@ public static function directoryList(string $directory, array $ignore = []): arr | |
* | ||
* Normalizes a file or directory path. | ||
* | ||
* @param string $path The file or directory path. | ||
* @param string $separator The directory separator. Defaults to DIRECTORY_SEPARATOR. | ||
* @return string The normalized file or directory path | ||
* @param string $path The file or directory path. | ||
* @param non-empty-string $separator The directory separator. Defaults to DIRECTORY_SEPARATOR. | ||
* @return string The normalized file or directory path | ||
*/ | ||
public static function normalizeFilePath(string $path, string $separator = DIRECTORY_SEPARATOR): string | ||
{ | ||
|
@@ -870,11 +875,11 @@ public static function fileRead(string $file): string|false | |
* @param int $flags Bitwise OR'ed set of flags for file_put_contents. One or | ||
* more of FILE_USE_INCLUDE_PATH, FILE_APPEND, LOCK_EX. | ||
* {@link http://php.net/file_put_contents} | ||
* @return string|false | ||
* @return string|int<0, max>|false | ||
* | ||
* @throws InvalidArgumentException|RandomException | ||
*/ | ||
public static function fileWrite(string $file, string $data = '', int $flags = 0): string|false | ||
public static function fileWrite(string $file, string $data = '', int $flags = 0): string|false|int | ||
{ | ||
// Sanity checks | ||
if (!is_readable($file)) { | ||
|
@@ -1118,6 +1123,7 @@ public static function getIpAddress(bool $trustProxy = false): string | |
|
||
if (!empty($ips)) { | ||
foreach ($ips AS $val) { | ||
/** @phpstan-ignore-next-line */ | ||
if (inet_ntop(inet_pton($val)) == $val AND static::isPublicIp($val)) { | ||
$ip = $val; | ||
break; | ||
|
@@ -1289,9 +1295,9 @@ public static function isHttps(): bool | |
* Retrieve the current URL. | ||
* | ||
* @param bool $parse True to return the url as an array, false otherwise. | ||
* @return string|array<mixed> | ||
* @return mixed | ||
*/ | ||
public static function currentUrl(bool $parse = false): string|array | ||
public static function currentUrl(bool $parse = false): mixed | ||
{ | ||
// Scheme | ||
$url = (static::isHttps()) ? 'https://' : 'http://'; | ||
|
@@ -1513,11 +1519,21 @@ public static function timezoneInfo(string $timezone): array | |
throw new InvalidArgumentException($e->getMessage(), 0, $e); | ||
} | ||
|
||
$location = $tz->getLocation(); | ||
|
||
if ($location == false) { | ||
$location = [ | ||
'country_code' => 'N/A', | ||
'latitude' => 'N/A', | ||
'longitude' => 'N/A' | ||
]; | ||
} | ||
|
||
$info = [ | ||
'offset' => $tz->getOffset(new DateTime('now', new DateTimeZone('GMT'))) / 3600, | ||
'country' => $tz->getLocation()['country_code'], | ||
'latitude' => $tz->getLocation()['latitude'], | ||
'longitude' => $tz->getLocation()['longitude'], | ||
'country' => $location['country_code'], | ||
'latitude' => $location['latitude'], | ||
'longitude' => $location['longitude'], | ||
'dst' => $tz->getTransitions($now = time(), $now)[0]['isdst'] | ||
]; | ||
unset($tz); | ||
|
@@ -1557,8 +1573,8 @@ public static function iniGet(string $option, bool $standardize = false): string | |
|
||
if ($standardize) { | ||
$value = match (static::lower($option)) { | ||
'yes', 'on', 'true', '1' => 1, | ||
default => 0 | ||
'yes', 'on', 'true', '1' => '1', | ||
default => '0' | ||
}; | ||
} | ||
return $value; | ||
|