Skip to content

Commit 355903d

Browse files
committed
refactor: remove slashes before each PHP native func
1 parent 9082585 commit 355903d

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Small code refactoring
77
- Added a new badge to a `README.md` file
88
- Moved scripts from `Makefile` to `composer.json`
9+
- Removed slashes before each PHP native function
910

1011
## v3.2.1 (2024-02-16)
1112

src/Lang.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Lang
4646
*/
4747
public static function set(string $lang, ?array $overwrites = []): void
4848
{
49-
self::$lang = \in_array($lang, self::getLanguagesSlugs(), true) ? $lang : 'en';
49+
self::$lang = in_array($lang, self::getLanguagesSlugs(), true) ? $lang : 'en';
5050
self::$overwrites = $overwrites ?? [];
5151
}
5252

@@ -72,24 +72,24 @@ public static function getRules(int $number, int $last_digit): array
7272
return [];
7373
}
7474

75-
return \call_user_func(self::$rules, $number, $last_digit);
75+
return call_user_func(self::$rules, $number, $last_digit);
7676
}
7777

7878
/**
7979
* @return string[]
8080
*/
8181
private static function getLanguagesSlugs(): array
8282
{
83-
$paths = \glob(__DIR__ . '/../resources/lang/*.php');
83+
$paths = glob(__DIR__ . '/../resources/lang/*.php');
8484

8585
if ($paths === false) {
8686
return [];
8787
}
8888

89-
return \array_map(static function ($path) {
90-
$chunks = \explode('/', $path);
91-
$file = \end($chunks);
92-
return \str_replace('.php', '', $file);
89+
return array_map(static function ($path) {
90+
$chunks = explode('/', $path);
91+
$file = end($chunks);
92+
return str_replace('.php', '', $file);
9393
}, $paths);
9494
}
9595

@@ -102,12 +102,12 @@ public static function includeTranslations(): void
102102
$path = __DIR__ . '/../resources/lang/' . self::$lang . '.php';
103103
$cached_translations = self::$included_files_cache[$path] ?? [];
104104

105-
$translations = \count($cached_translations) > 0 ? $cached_translations : require $path;
105+
$translations = count($cached_translations) > 0 ? $cached_translations : require $path;
106106

107107
self::$included_files_cache[$path] = $translations;
108108

109-
if (\count(self::$overwrites) > 0) {
110-
$translations = \array_merge($translations, self::$overwrites);
109+
if (count(self::$overwrites) > 0) {
110+
$translations = array_merge($translations, self::$overwrites);
111111
}
112112

113113
self::$translations = $translations;

src/TimeAgo.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function singleton(): self
4848
*/
4949
public static function trans($date, $options = []): string
5050
{
51-
if (\is_int($options)) {
51+
if (is_int($options)) {
5252
$options = [$options];
5353
}
5454

@@ -75,19 +75,19 @@ private function handle(int $date_timestamp, ?array $options = []): string
7575

7676
$this->validateOptions();
7777

78-
$seconds = \time() - $date_timestamp;
78+
$seconds = time() - $date_timestamp;
7979

8080
if ($seconds < 0) {
81-
$seconds = $date_timestamp - \time();
81+
$seconds = $date_timestamp - time();
8282
$this->options[] = Option::UPCOMING;
8383
}
8484

85-
$minutes = (int) \round($seconds / 60);
86-
$hours = (int) \round($seconds / 3600);
87-
$days = (int) \round($seconds / 86400);
88-
$weeks = (int) \round($seconds / 604800);
89-
$months = (int) \round($seconds / 2629440);
90-
$years = (int) \round($seconds / 31553280);
85+
$minutes = (int) round($seconds / 60);
86+
$hours = (int) round($seconds / 3600);
87+
$days = (int) round($seconds / 86400);
88+
$weeks = (int) round($seconds / 604800);
89+
$months = (int) round($seconds / 2629440);
90+
$years = (int) round($seconds / 31553280);
9191

9292
switch (true) {
9393
case $this->optionIsSet(Option::ONLINE) && $seconds < 60:
@@ -113,7 +113,7 @@ private function handle(int $date_timestamp, ?array $options = []): string
113113

114114
private function optionIsSet(int $option): bool
115115
{
116-
return \in_array($option, $this->options, true);
116+
return in_array($option, $this->options, true);
117117
}
118118

119119
/**
@@ -151,7 +151,7 @@ private function getWords(string $type, int $number): string
151151
*/
152152
private function getLanguageForm(int $number): string
153153
{
154-
$last_digit = (int) \substr((string) $number, -1);
154+
$last_digit = (int) substr((string) $number, -1);
155155

156156
/**
157157
* @var string $form_name
@@ -183,7 +183,7 @@ private function ruleIsTrue($rules): bool
183183
*/
184184
private function ruleIsBooleanTrue($rules): bool
185185
{
186-
return \is_bool($rules) && $rules;
186+
return is_bool($rules) && $rules;
187187
}
188188

189189
/**
@@ -193,7 +193,7 @@ private function ruleIsBooleanTrue($rules): bool
193193
*/
194194
private function ruleIsArrayWithTrueItem($rules): bool
195195
{
196-
return \is_array($rules) && \in_array(true, $rules, true);
196+
return is_array($rules) && in_array(true, $rules, true);
197197
}
198198

199199
/**
@@ -203,7 +203,7 @@ private function validateOptions(): void
203203
{
204204
if ($this->optionIsSet(Option::UPCOMING)) {
205205
$msg = 'Option::UPCOMING is deprecated. Read more: https://github.com/SerhiiCho/ago/issues/34';
206-
\trigger_error($msg, E_USER_DEPRECATED);
206+
trigger_error($msg, E_USER_DEPRECATED);
207207
}
208208

209209
if ($this->optionIsSet(Option::JUST_NOW) && $this->optionIsSet(Option::ONLINE)) {

0 commit comments

Comments
 (0)