Skip to content

Commit

Permalink
Merge pull request #113 from honeybadger-io/checkin-using-name
Browse files Browse the repository at this point in the history
feat: checkin using name
  • Loading branch information
subzero10 authored Oct 17, 2023
2 parents 3351751 + 2dacde4 commit 5f62ca9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/Commands/HoneybadgerCheckinCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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
*/
Expand All @@ -30,8 +31,9 @@ class HoneybadgerCheckinCommand extends Command
public function handle(Reporter $honeybadger)
{
try {
$honeybadger->checkin($this->apiKey());
$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());
}
Expand All @@ -42,7 +44,7 @@ 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]
Expand Down
12 changes: 6 additions & 6 deletions src/HoneybadgerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
});
Expand Down

0 comments on commit 5f62ca9

Please sign in to comment.