From b36a3009dd52391fba57fd72cea73356595c81e3 Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Tue, 11 Feb 2020 12:32:41 -0500 Subject: [PATCH] Cleanup Utils #467 (#547) * Remove Utils Facade --- .travis.yml | 8 +- .travis/deploy_script.sh | 7 +- app/Console/Commands/AcarsReplay.php | 4 +- app/Contracts/Award.php | 2 +- app/Facades/Utils.php | 222 ------------------ .../Controllers/Admin/PirepController.php | 3 +- app/Http/Controllers/Admin/UserController.php | 2 +- .../Controllers/Auth/RegisterController.php | 2 +- .../Controllers/Frontend/PirepController.php | 3 +- .../Frontend/ProfileController.php | 2 +- app/Providers/DirectiveServiceProvider.php | 23 ++ app/Support/Dates.php | 30 +++ app/Support/HttpClient.php | 16 +- app/Support/Units/Time.php | 117 ++++++++- app/Support/Utils.php | 31 +++ config/app.php | 10 +- .../Services/Importers/UserImport.php | 5 +- .../Http/Controllers/InstallerController.php | 2 +- .../views/admin/aircraft/table.blade.php | 2 +- .../views/admin/pireps/pirep_card.blade.php | 2 +- .../views/admin/pireps/show_fields.blade.php | 2 +- resources/views/admin/users/fields.blade.php | 2 +- .../layouts/default/dashboard/index.blade.php | 2 +- .../default/pireps/pirep_card.blade.php | 20 +- .../layouts/default/profile/index.blade.php | 4 +- .../layouts/default/users/table.blade.php | 2 +- tests/UtilsTest.php | 43 ++-- 27 files changed, 280 insertions(+), 288 deletions(-) delete mode 100644 app/Facades/Utils.php create mode 100644 app/Providers/DirectiveServiceProvider.php diff --git a/.travis.yml b/.travis.yml index 7bd999367..8ea494f09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ php: # - '7.3' - '7.4' -env: - - DB=mysql +#env: +# - DB=mysql # - DB=mariadb cache: @@ -23,8 +23,8 @@ cache: services: - mysql -addons: - mariadb: '10.2' +#addons: +# mariadb: '10.2' install: - php --version diff --git a/.travis/deploy_script.sh b/.travis/deploy_script.sh index bc6670fa5..e9f61d824 100755 --- a/.travis/deploy_script.sh +++ b/.travis/deploy_script.sh @@ -107,9 +107,12 @@ if [ "$TRAVIS" = "true" ]; then make clean cd /tmp + ls -al $TRAVIS_BUILD_DIR/../ + tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR/../ sha256sum $TAR_NAME >"$TAR_NAME.sha256" tar2zip $TAR_NAME + sha256sum $ZIP_NAME >"$ZIP_NAME.sha256" ls -al /tmp @@ -117,8 +120,8 @@ if [ "$TRAVIS" = "true" ]; then mkdir -p $TRAVIS_BUILD_DIR/build cd $TRAVIS_BUILD_DIR/build - mv "/tmp/$TAR_NAME" "/tmp/$ZIP_NAME" "/tmp/$TAR_NAME.sha256" . - artifacts upload --target-paths "/" $ZIP_NAME $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_NAME.sha256 + mv "/tmp/$TAR_NAME" "/tmp/$ZIP_NAME" "/tmp/$TAR_NAME.sha256" "/tmp/$ZIP_NAME.sha256". + artifacts upload --target-paths "/" $ZIP_NAME $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_NAME.sha256 $ZIP_NAME.sha256 # Upload the version for a tagged release. Move to a version file in different # tags. Within phpVMS, we have an option of which version to track in the admin diff --git a/app/Console/Commands/AcarsReplay.php b/app/Console/Commands/AcarsReplay.php index 0fef140f1..2734bb004 100644 --- a/app/Console/Commands/AcarsReplay.php +++ b/app/Console/Commands/AcarsReplay.php @@ -3,7 +3,7 @@ namespace App\Console\Commands; use App\Contracts\Command; -use App\Facades\Utils; +use App\Support\Units\Time; use GuzzleHttp\Client; use Illuminate\Database\Eloquent\Collection; @@ -64,7 +64,7 @@ public function __construct() protected function startPirep($flight): string { // convert the planned flight time to be completely in minutes - $pft = Utils::hoursToMinutes( + $pft = Time::hoursToMinutes( $flight->planned_hrsenroute, $flight->planned_minenroute ); diff --git a/app/Contracts/Award.php b/app/Contracts/Award.php index 36c382e28..d7c3d337c 100644 --- a/app/Contracts/Award.php +++ b/app/Contracts/Award.php @@ -2,10 +2,10 @@ namespace App\Contracts; -use App\Facades\Utils; use App\Models\Award as AwardModel; use App\Models\User; use App\Models\UserAward; +use App\Support\Utils; use Exception; use Illuminate\Support\Facades\Log; diff --git a/app/Facades/Utils.php b/app/Facades/Utils.php deleted file mode 100644 index 8a9973e07..000000000 --- a/app/Facades/Utils.php +++ /dev/null @@ -1,222 +0,0 @@ -request('GET', $uri, $opts); - - $body = $response->getBody()->getContents(); - if ($response->getHeader('content-type') === 'application/json') { - $body = \GuzzleHttp\json_decode($body); - } - - return $body; - } - - /** - * Returns a 40 character API key that a user can use - * - * @return string - */ - public static function generateApiKey(): string - { - $key = substr(sha1(time().mt_rand()), 0, 20); - return $key; - } - - /** - * @param string $minutes - * - * @return array - */ - public static function minutesToTimeParts($minutes): array - { - $hours = floor($minutes / 60); - $minutes %= 60; - - return ['h' => $hours, 'm' => $minutes]; - } - - public static function minutesToTimeString($minutes): string - { - $hm = self::minutesToTimeParts($minutes); - return $hm['h'].'h '.$hm['m'].'m'; - } - - /** - * Convert seconds to an array of hours, minutes, seconds - * - * @param int $seconds - * - * @throws \Exception - * - * @return array['h', 'm', 's'] - */ - public static function secondsToTimeParts($seconds): array - { - $dtF = new \DateTimeImmutable('@0', new \DateTimeZone('UTC')); - $dtT = new \DateTimeImmutable("@$seconds", new \DateTimeZone('UTC')); - - $t = $dtF->diff($dtT); - - $retval = []; - $retval['h'] = (int) $t->format('%h'); - $retval['m'] = (int) $t->format('%i'); - $retval['s'] = (int) $t->format('%s'); - - return $retval; - } - - /** - * Convert seconds to HH MM format - * - * @param int $seconds - * @param bool $incl_sec - * - * @throws \Exception - * - * @return string - */ - public static function secondsToTimeString($seconds, $incl_sec = false): string - { - $hms = self::secondsToTimeParts($seconds); - $format = $hms['h'].'h '.$hms['m'].'m'; - if ($incl_sec) { - $format .= ' '.$hms['s'].'s'; - } - - return $format; - } - - /** - * @param $minutes - * - * @return float|int - */ - public static function minutesToSeconds($minutes) - { - return $minutes * 60; - } - - /** - * Convert the seconds to minutes and then round it up - * - * @param $seconds - * - * @return float|int - */ - public static function secondsToMinutes($seconds) - { - return ceil($seconds / 60); - } - - /** - * Convert hours to minutes. Pretty complex - * - * @param $minutes - * - * @return float|int - */ - public static function minutesToHours($minutes) - { - return $minutes / 60; - } - - /** - * @param $hours - * @param null $minutes - * - * @return float|int - */ - public static function hoursToMinutes($hours, $minutes = null) - { - $total = (int) $hours * 60; - if ($minutes) { - $total += (int) $minutes; - } - - return $total; - } - - /** - * Bitwise operator for setting days of week to integer field - * - * @param int $datefield initial datefield - * @param array $day_enums Array of values from config("enum.days") - * - * @return int - */ - public static function setDays(int $datefield, array $day_enums): int - { - foreach ($day_enums as $day) { - $datefield |= $day; - } - - return $datefield; - } - - /** - * Bit check if a day exists within a integer bitfield - * - * @param int $datefield datefield from database - * @param int $day_enum Value from config("enum.days") - * - * @return bool - */ - public static function hasDay(int $datefield, int $day_enum): bool - { - return ($datefield & $day_enum) === $datefield; - } -} diff --git a/app/Http/Controllers/Admin/PirepController.php b/app/Http/Controllers/Admin/PirepController.php index ac12a15ac..20f19b401 100644 --- a/app/Http/Controllers/Admin/PirepController.php +++ b/app/Http/Controllers/Admin/PirepController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Admin; use App\Contracts\Controller; -use App\Facades\Utils; use App\Http\Requests\CreatePirepRequest; use App\Http\Requests\UpdatePirepRequest; use App\Models\Enums\PirepSource; @@ -260,7 +259,7 @@ public function store(CreatePirepRequest $request) $hours = (int) $attrs['hours']; $minutes = (int) $attrs['minutes']; - $pirep->flight_time = Utils::hoursToMinutes($hours) + $minutes; + $pirep->flight_time = Time::hoursToMinutes($hours) + $minutes; $this->saveCustomFields($pirep, $request); $this->saveFares($pirep, $request); diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 0f6692123..563c252d1 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Admin; use App\Contracts\Controller; -use App\Facades\Utils; use App\Http\Requests\CreateUserRequest; use App\Http\Requests\UpdateUserRequest; use App\Models\Rank; @@ -15,6 +14,7 @@ use App\Repositories\UserRepository; use App\Services\UserService; use App\Support\Timezonelist; +use App\Support\Utils; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index ff52dfe71..a10f45eb7 100755 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Auth; use App\Contracts\Controller; -use App\Facades\Utils; use App\Models\Enums\UserState; use App\Models\User; use App\Repositories\AirlineRepository; @@ -11,6 +10,7 @@ use App\Services\UserService; use App\Support\Countries; use App\Support\Timezonelist; +use App\Support\Utils; use Illuminate\Contracts\Validation\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Http\Request; diff --git a/app/Http/Controllers/Frontend/PirepController.php b/app/Http/Controllers/Frontend/PirepController.php index 249c4ae58..f0d76ac58 100644 --- a/app/Http/Controllers/Frontend/PirepController.php +++ b/app/Http/Controllers/Frontend/PirepController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Frontend; use App\Contracts\Controller; -use App\Facades\Utils; use App\Http\Requests\CreatePirepRequest; use App\Http\Requests\UpdatePirepRequest; use App\Models\Enums\PirepSource; @@ -324,7 +323,7 @@ public function store(CreatePirepRequest $request) // Any special fields $hours = (int) $request->input('hours', 0); $minutes = (int) $request->input('minutes', 0); - $pirep->flight_time = Utils::hoursToMinutes($hours) + $minutes; + $pirep->flight_time = Time::hoursToMinutes($hours) + $minutes; // Set the correct fuel units $pirep->block_fuel = new Fuel((float) $request->input('block_fuel'), setting('units.fuel')); diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index 2ef5f421f..abed89682 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -3,13 +3,13 @@ namespace App\Http\Controllers\Frontend; use App\Contracts\Controller; -use App\Facades\Utils; use App\Models\User; use App\Repositories\AirlineRepository; use App\Repositories\AirportRepository; use App\Repositories\UserRepository; use App\Support\Countries; use App\Support\Timezonelist; +use App\Support\Utils; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; diff --git a/app/Providers/DirectiveServiceProvider.php b/app/Providers/DirectiveServiceProvider.php new file mode 100644 index 000000000..3f7697f7d --- /dev/null +++ b/app/Providers/DirectiveServiceProvider.php @@ -0,0 +1,23 @@ +"; + }); + + Blade::directive('minutestohours', function ($expr) { + return ""; + }); + } +} diff --git a/app/Support/Dates.php b/app/Support/Dates.php index a97cc457a..6728a6fe7 100644 --- a/app/Support/Dates.php +++ b/app/Support/Dates.php @@ -6,6 +6,36 @@ class Dates { + /** + * Bitwise operator for setting days of week to integer field + * + * @param int $datefield initial datefield + * @param array $day_enums Array of values from config("enum.days") + * + * @return int + */ + public static function setDays(int $datefield, array $day_enums): int + { + foreach ($day_enums as $day) { + $datefield |= $day; + } + + return $datefield; + } + + /** + * Bit check if a day exists within a integer bitfield + * + * @param int $datefield datefield from database + * @param int $day_enum Value from config("enum.days") + * + * @return bool + */ + public static function hasDay(int $datefield, int $day_enum): bool + { + return ($datefield & $day_enum) === $datefield; + } + /** * Get the list of months, given a start date * diff --git a/app/Support/HttpClient.php b/app/Support/HttpClient.php index ac3349203..6bb2f9d0c 100644 --- a/app/Support/HttpClient.php +++ b/app/Support/HttpClient.php @@ -55,10 +55,18 @@ public function get($uri, array $opts = []) */ public function download($uri, $local_path) { - $response = $this->httpClient->request('GET', $uri, [ - 'sink' => $local_path, - ]); + $opts = []; + if ($local_path !== null) { + $opts['sink'] = $local_path; + } + + $response = $this->httpClient->request('GET', $uri, $opts); - return $response; + $body = $response->getBody()->getContents(); + if ($response->getHeader('content-type') === 'application/json') { + $body = \GuzzleHttp\json_decode($body); + } + + return $body; } } diff --git a/app/Support/Units/Time.php b/app/Support/Units/Time.php index 29d09c244..89add1530 100644 --- a/app/Support/Units/Time.php +++ b/app/Support/Units/Time.php @@ -4,9 +4,6 @@ use Illuminate\Contracts\Support\Arrayable; -/** - * Class Time - */ class Time implements Arrayable { public $hours; @@ -90,4 +87,118 @@ public function toArray() { return $this->getMinutes(); } + + /** + * @param string $minutes + * + * @return array + */ + public static function minutesToTimeParts($minutes): array + { + $hours = floor($minutes / 60); + $minutes %= 60; + + return ['h' => $hours, 'm' => $minutes]; + } + + public static function minutesToTimeString($minutes): string + { + $hm = self::minutesToTimeParts($minutes); + return $hm['h'].'h '.$hm['m'].'m'; + } + + /** + * Convert seconds to an array of hours, minutes, seconds + * + * @param int $seconds + * + * @throws \Exception + * + * @return array['h', 'm', 's'] + */ + public static function secondsToTimeParts($seconds): array + { + $dtF = new \DateTimeImmutable('@0', new \DateTimeZone('UTC')); + $dtT = new \DateTimeImmutable("@$seconds", new \DateTimeZone('UTC')); + + $t = $dtF->diff($dtT); + + $retval = []; + $retval['h'] = (int) $t->format('%h'); + $retval['m'] = (int) $t->format('%i'); + $retval['s'] = (int) $t->format('%s'); + + return $retval; + } + + /** + * Convert seconds to HH MM format + * + * @param int $seconds + * @param bool $incl_sec + * + * @throws \Exception + * + * @return string + */ + public static function secondsToTimeString($seconds, $incl_sec = false): string + { + $hms = self::secondsToTimeParts($seconds); + $format = $hms['h'].'h '.$hms['m'].'m'; + if ($incl_sec) { + $format .= ' '.$hms['s'].'s'; + } + + return $format; + } + + /** + * @param $minutes + * + * @return float|int + */ + public static function minutesToSeconds($minutes) + { + return $minutes * 60; + } + + /** + * Convert the seconds to minutes and then round it up + * + * @param $seconds + * + * @return float|int + */ + public static function secondsToMinutes($seconds) + { + return ceil($seconds / 60); + } + + /** + * Convert hours to minutes. Pretty complex + * + * @param $minutes + * + * @return float|int + */ + public static function minutesToHours($minutes) + { + return $minutes / 60; + } + + /** + * @param $hours + * @param null $minutes + * + * @return float|int + */ + public static function hoursToMinutes($hours, $minutes = null) + { + $total = (int) $hours * 60; + if ($minutes) { + $total += (int) $minutes; + } + + return $total; + } } diff --git a/app/Support/Utils.php b/app/Support/Utils.php index 6889e2bbf..f21b98d30 100644 --- a/app/Support/Utils.php +++ b/app/Support/Utils.php @@ -11,6 +11,37 @@ */ class Utils { + /** + * Returns a 40 character API key that a user can use + * + * @return string + */ + public static function generateApiKey(): string + { + $key = substr(sha1(time().mt_rand()), 0, 20); + return $key; + } + + /** + * Simple check on the first character if it's an object or not + * + * @param $obj + * + * @return bool + */ + public static function isObject($obj): bool + { + if (!$obj) { + return false; + } + + if ($obj[0] === '{' || $obj[0] === '[') { + return true; + } + + return false; + } + /** * Enable the debug toolbar */ diff --git a/config/app.php b/config/app.php index 3697095c8..429035063 100755 --- a/config/app.php +++ b/config/app.php @@ -74,13 +74,14 @@ * Application Service Providers... */ App\Providers\AppServiceProvider::class, - App\Providers\CronServiceProvider::class, - App\Providers\BroadcastServiceProvider::class, App\Providers\AuthServiceProvider::class, + App\Providers\BindServiceProviders::class, + App\Providers\BroadcastServiceProvider::class, + App\Providers\CronServiceProvider::class, + App\Providers\DirectiveServiceProvider::class, App\Providers\EventServiceProvider::class, - App\Providers\RouteServiceProvider::class, App\Providers\MeasurementsProvider::class, - App\Providers\BindServiceProviders::class, + App\Providers\RouteServiceProvider::class, ], 'aliases' => [ @@ -120,7 +121,6 @@ 'Theme' => Igaster\LaravelTheme\Facades\Theme::class, 'Updater' => Codedge\Updater\UpdaterFacade::class, 'URL' => Illuminate\Support\Facades\URL::class, - 'Utils' => App\Facades\Utils::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'Version' => PragmaRX\Version\Package\Facade::class, 'View' => Illuminate\Support\Facades\View::class, diff --git a/modules/Importer/Services/Importers/UserImport.php b/modules/Importer/Services/Importers/UserImport.php index 6a417d373..187946c56 100644 --- a/modules/Importer/Services/Importers/UserImport.php +++ b/modules/Importer/Services/Importers/UserImport.php @@ -2,10 +2,11 @@ namespace Modules\Importer\Services\Importers; -use App\Facades\Utils; use App\Models\Enums\UserState; use App\Models\User; use App\Services\UserService; +use App\Support\Units\Time; +use App\Support\Utils; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; @@ -62,7 +63,7 @@ public function run($start = 0) 'home_airport_id' => $row->hub, 'curr_airport_id' => $row->hub, 'flights' => (int) $row->totalflights, - 'flight_time' => Utils::hoursToMinutes($row->totalhours), + 'flight_time' => Time::hoursToMinutes($row->totalhours), 'state' => $state, 'created_at' => $this->parseDate($row->joindate), ]; diff --git a/modules/Installer/Http/Controllers/InstallerController.php b/modules/Installer/Http/Controllers/InstallerController.php index 8c04c9226..2c773676b 100644 --- a/modules/Installer/Http/Controllers/InstallerController.php +++ b/modules/Installer/Http/Controllers/InstallerController.php @@ -3,7 +3,6 @@ namespace Modules\Installer\Http\Controllers; use App\Contracts\Controller; -use App\Facades\Utils; use App\Models\User; use App\Repositories\AirlineRepository; use App\Services\AnalyticsService; @@ -13,6 +12,7 @@ use App\Services\Installer\SeederService; use App\Services\UserService; use App\Support\Countries; +use App\Support\Utils; use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; diff --git a/resources/views/admin/aircraft/table.blade.php b/resources/views/admin/aircraft/table.blade.php index 9a06edc43..b329c227a 100644 --- a/resources/views/admin/aircraft/table.blade.php +++ b/resources/views/admin/aircraft/table.blade.php @@ -24,7 +24,7 @@ {{ $ac->airport_id }} - {{ Utils::minutesToTimeString($ac->flight_hours) }} + @minutestotime($ac->flight_hours) @if($ac->status == \App\Models\Enums\AircraftStatus::ACTIVE) diff --git a/resources/views/admin/pireps/pirep_card.blade.php b/resources/views/admin/pireps/pirep_card.blade.php index 5e2d70a8d..73943fb65 100644 --- a/resources/views/admin/pireps/pirep_card.blade.php +++ b/resources/views/admin/pireps/pirep_card.blade.php @@ -35,7 +35,7 @@
Flight Time  - {{ Utils::minutesToTimeString($pirep->flight_time) }} + @minutestotime($pirep->flight_time)
@if($pirep->aircraft) diff --git a/resources/views/admin/pireps/show_fields.blade.php b/resources/views/admin/pireps/show_fields.blade.php index 7b50340e7..556063b41 100644 --- a/resources/views/admin/pireps/show_fields.blade.php +++ b/resources/views/admin/pireps/show_fields.blade.php @@ -56,7 +56,7 @@ Flight Time - {{ Utils::minutesToTimeString($pirep->flight_time) }} + @minutestotime($pirep->flight_time) Flight Level diff --git a/resources/views/admin/users/fields.blade.php b/resources/views/admin/users/fields.blade.php index 402734637..3ff751bc9 100644 --- a/resources/views/admin/users/fields.blade.php +++ b/resources/views/admin/users/fields.blade.php @@ -104,7 +104,7 @@ Flight Time - {{ Utils::minutesToTimeString($user->flight_time) }} + @minutestotime($user->flight_time) IP Address diff --git a/resources/views/layouts/default/dashboard/index.blade.php b/resources/views/layouts/default/dashboard/index.blade.php index d8875612f..7bae1fa8a 100644 --- a/resources/views/layouts/default/dashboard/index.blade.php +++ b/resources/views/layouts/default/dashboard/index.blade.php @@ -25,7 +25,7 @@
-

{{ \App\Facades\Utils::minutesToTimeString($user->flight_time, false)}}

+

@minutestotime($user->flight_time), {{$user->flight_time}}

@lang('dashboard.totalhours')
diff --git a/resources/views/layouts/default/pireps/pirep_card.blade.php b/resources/views/layouts/default/pireps/pirep_card.blade.php index b9cb772c6..29d588a53 100644 --- a/resources/views/layouts/default/pireps/pirep_card.blade.php +++ b/resources/views/layouts/default/pireps/pirep_card.blade.php @@ -25,15 +25,15 @@ class="btn btn-sm btn-info">@lang('common.edit')
@if($pirep->state === PirepState::PENDING)
- @elseif($pirep->state === PirepState::ACCEPTED) -
- @elseif($pirep->state === PirepState::REJECTED) -
- @else -
- @endif - {{ PirepState::label($pirep->state) }}
-
+ @elseif($pirep->state === PirepState::ACCEPTED) +
+ @elseif($pirep->state === PirepState::REJECTED) +
+ @else +
+ @endif + {{ PirepState::label($pirep->state) }}
+
@@ -41,7 +41,7 @@ class="btn btn-sm btn-info">@lang('common.edit') - + diff --git a/resources/views/layouts/default/profile/index.blade.php b/resources/views/layouts/default/profile/index.blade.php index 3f92f2af8..36fdc0390 100644 --- a/resources/views/layouts/default/profile/index.blade.php +++ b/resources/views/layouts/default/profile/index.blade.php @@ -47,7 +47,7 @@
@@ -74,7 +74,7 @@
diff --git a/resources/views/layouts/default/users/table.blade.php b/resources/views/layouts/default/users/table.blade.php index d6a00f10c..565b12447 100644 --- a/resources/views/layouts/default/users/table.blade.php +++ b/resources/views/layouts/default/users/table.blade.php @@ -41,7 +41,7 @@ @endif
- + @endforeach diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 7c27e4dce..cdd37a6cb 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -1,12 +1,15 @@ assertNotNull($carbon); } @@ -15,46 +18,49 @@ public function testDates() */ public function testSecondsToTimeParts() { - $t = Utils::secondsToTimeParts(3600); + $t = Time::secondsToTimeParts(3600); $this->assertEquals(['h' => 1, 'm' => 0, 's' => 0], $t); - $t = Utils::secondsToTimeParts(3720); + $t = Time::secondsToTimeParts(3720); $this->assertEquals(['h' => 1, 'm' => 2, 's' => 0], $t); - $t = Utils::secondsToTimeParts(3722); + $t = Time::secondsToTimeParts(3722); $this->assertEquals(['h' => 1, 'm' => 2, 's' => 2], $t); - $t = Utils::secondsToTimeParts(60); + $t = Time::secondsToTimeParts(60); $this->assertEquals(['h' => 0, 'm' => 1, 's' => 0], $t); - $t = Utils::secondsToTimeParts(62); + $t = Time::secondsToTimeParts(62); $this->assertEquals(['h' => 0, 'm' => 1, 's' => 2], $t); } + /** + * @throws \Exception + */ public function testSecondsToTime() { - $t = Utils::secondsToTimeString(3600); + $t = Time::secondsToTimeString(3600); $this->assertEquals('1h 0m', $t); - $t = Utils::secondsToTimeString(3720); + $t = Time::secondsToTimeString(3720); $this->assertEquals('1h 2m', $t); - $t = Utils::secondsToTimeString(3722); + $t = Time::secondsToTimeString(3722); $this->assertEquals('1h 2m', $t); - $t = Utils::secondsToTimeString(3722, true); + $t = Time::secondsToTimeString(3722, true); $this->assertEquals('1h 2m 2s', $t); } public function testMinutesToTime() { - $t = Utils::minutesToTimeParts(65); + $t = Time::minutesToTimeParts(65); $this->assertEquals(['h' => 1, 'm' => 5], $t); - $t = Utils::minutesToTimeString(65); + $t = Time::minutesToTimeString(65); $this->assertEquals('1h 5m', $t); - $t = Utils::minutesToTimeString(43200); + $t = Time::minutesToTimeString(43200); $this->assertEquals('720h 0m', $t); } @@ -64,9 +70,12 @@ public function testApiKey() $this->assertNotNull($api_key); } + /** + * @throws \Exception + */ public function testHexCode() { - $hex_code = \App\Support\ICAO::createHexCode(); + $hex_code = ICAO::createHexCode(); $this->assertNotNull($hex_code); } @@ -82,9 +91,9 @@ public function testGetDomain() ]; foreach ($tests as $case) { - $this->assertEquals('phpvms.net', \App\Support\Utils::getRootDomain($case)); + $this->assertEquals('phpvms.net', Utils::getRootDomain($case)); } - $this->assertEquals('phpvms', \App\Support\Utils::getRootDomain('http://phpvms')); + $this->assertEquals('phpvms', Utils::getRootDomain('http://phpvms')); } }
@lang('pireps.flighttime') {{ Utils::minutesToTimeString($pirep->flight_time) }}@minutestotime($pirep->flight_time)
@lang('common.aircraft') {{ $user->flights }}{{ \App\Facades\Utils::minutesToTimeString($user->flight_time) }}@minutestotime($user->flight_time)