From ba9bc1fcacf47ff244ea98c16f6c99c1a9858d5d Mon Sep 17 00:00:00 2001 From: Pangratios Cosma Date: Fri, 13 Oct 2023 11:59:13 +0300 Subject: [PATCH 1/3] feat: checkin using name --- src/Commands/HoneybadgerCheckinCommand.php | 12 ++++++------ src/HoneybadgerServiceProvider.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Commands/HoneybadgerCheckinCommand.php b/src/Commands/HoneybadgerCheckinCommand.php index e18972a..552153c 100644 --- a/src/Commands/HoneybadgerCheckinCommand.php +++ b/src/Commands/HoneybadgerCheckinCommand.php @@ -13,7 +13,7 @@ class HoneybadgerCheckinCommand extends Command * * @var string */ - protected $signature = 'honeybadger:checkin {id}'; + protected $signature = 'honeybadger:checkin {idOrName}'; /** * The console command description. @@ -30,7 +30,7 @@ class HoneybadgerCheckinCommand extends Command public function handle(Reporter $honeybadger) { try { - $honeybadger->checkin($this->apiKey()); + $honeybadger->checkin($this->checkinIdOrName()); $this->info(sprintf('Checkin %s was sent to Honeybadger', $this->argument('id'))); } catch (Exception $e) { $this->error($e->getMessage()); @@ -42,10 +42,10 @@ public function handle(Reporter $honeybadger) * * @return string */ - private function apiKey(): string + private function checkinIdOrName(): string { - return is_array($this->argument('id')) - ? $this->argument('id')[0] - : $this->argument('id'); + return is_array($this->argument('idOrName')) + ? $this->argument('idOrName')[0] + : $this->argument('idOrName'); } } diff --git a/src/HoneybadgerServiceProvider.php b/src/HoneybadgerServiceProvider.php index 0743310..6cd8d25 100644 --- a/src/HoneybadgerServiceProvider.php +++ b/src/HoneybadgerServiceProvider.php @@ -120,19 +120,19 @@ private function bindCommands() private function registerEventHooks() { /** @param string|array|null $environments */ - Event::macro('thenPingHoneybadger', function (string $id, $environments = null) { - return $this->then(function () use ($id, $environments) { + Event::macro('thenPingHoneybadger', function (string $checkinIdOrName, $environments = null) { + return $this->then(function () use ($checkinIdOrName, $environments) { if ($environments === null || app()->environment($environments)) { - app(Reporter::class)->checkin($id); + app(Reporter::class)->checkin($checkinIdOrName); } }); }); /** @param string|array|null $environments */ - Event::macro('pingHoneybadgerOnSuccess', function (string $id, $environments = null) { - return $this->onSuccess(function () use ($id, $environments) { + Event::macro('pingHoneybadgerOnSuccess', function (string $checkinIdOrName, $environments = null) { + return $this->onSuccess(function () use ($checkinIdOrName, $environments) { if ($environments === null || app()->environment($environments)) { - app(Reporter::class)->checkin($id); + app(Reporter::class)->checkin($checkinIdOrName); } }); }); From 6e87089d3205d46df8a1dd75b4181094dfa0bd2c Mon Sep 17 00:00:00 2001 From: Pangratios Cosma Date: Fri, 13 Oct 2023 12:02:21 +0300 Subject: [PATCH 2/3] feat: checkin using name --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46a0238..d7d9af4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Modify parameter names to be more descriptive (from $id to $idOrName) ## [3.16.0] - 2023-10-06 ### Added From 2dacde42305ae2be613382f8abda63d8a4f42ba9 Mon Sep 17 00:00:00 2001 From: Pangratios Cosma Date: Fri, 13 Oct 2023 12:13:28 +0300 Subject: [PATCH 3/3] chore: revert command argument for backwards compatibility --- src/Commands/HoneybadgerCheckinCommand.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Commands/HoneybadgerCheckinCommand.php b/src/Commands/HoneybadgerCheckinCommand.php index 552153c..fb9d2b8 100644 --- a/src/Commands/HoneybadgerCheckinCommand.php +++ b/src/Commands/HoneybadgerCheckinCommand.php @@ -10,10 +10,11 @@ class HoneybadgerCheckinCommand extends Command { /** * The name and signature of the console command. + * "id" can be the check-in ID or the check-in name. * * @var string */ - protected $signature = 'honeybadger:checkin {idOrName}'; + protected $signature = 'honeybadger:checkin {id}'; /** * The console command description. @@ -30,8 +31,9 @@ class HoneybadgerCheckinCommand extends Command public function handle(Reporter $honeybadger) { try { - $honeybadger->checkin($this->checkinIdOrName()); - $this->info(sprintf('Checkin %s was sent to Honeybadger', $this->argument('id'))); + $idOrName = $this->checkinIdOrName(); + $honeybadger->checkin($idOrName); + $this->info(sprintf('Checkin %s was sent to Honeybadger', $idOrName)); } catch (Exception $e) { $this->error($e->getMessage()); } @@ -44,8 +46,8 @@ public function handle(Reporter $honeybadger) */ private function checkinIdOrName(): string { - return is_array($this->argument('idOrName')) - ? $this->argument('idOrName')[0] - : $this->argument('idOrName'); + return is_array($this->argument('id')) + ? $this->argument('id')[0] + : $this->argument('id'); } }