Skip to content

Commit

Permalink
Fix tags
Browse files Browse the repository at this point in the history
  • Loading branch information
DavydeVries committed Jan 25, 2022
1 parent e4bc83e commit 7cf090c
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/OpsGenie.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class incident
*/
private $object = [
'priority' => 'P3',
'tags' => [],
];

/**
Expand All @@ -58,6 +59,11 @@ class incident
public function __construct($data, $parent)
{
$this->parent = $parent;

if (config('opsgenie.tags')) {
$defaultTags = explode(',', config('opsgenie.tags'));
$this->object['tags'] = array_merge($this->object['tags'], $defaultTags);
}
}

/**
Expand Down Expand Up @@ -210,22 +216,13 @@ public function details(array $details = [])
*/
public function tags(array $tags = [])
{
if (config('opsgenie.tags')) {
$defaultTags = explode(',', config('opsgenie.tags'));
$tags = array_merge($defaultTags, $tags);
}

$this->object['tags'] = $tags;
$this->object['tags'] = array_merge($this->object['tags'], $tags);

return $this;
}

public function send()
{
if (config('opsgenie.tags')) {
$this->tags();
}

try {
$client = new Client();

Expand Down Expand Up @@ -253,6 +250,7 @@ class alert
*/
private $object = [
'priority' => 'P3',
'tags' => [],
];

/**
Expand All @@ -267,6 +265,11 @@ class alert
public function __construct($data, $parent)
{
$this->parent = $parent;

if (config('opsgenie.tags')) {
$defaultTags = explode(',', config('opsgenie.tags'));
$this->object['tags'] = array_merge($this->object['tags'], $defaultTags);
}
}

/**
Expand Down Expand Up @@ -419,12 +422,7 @@ public function details(array $details = [])
*/
public function tags(array $tags = [])
{
if (config('opsgenie.tags')) {
$defaultTags = explode(',', config('opsgenie.tags'));
$tags = array_merge($defaultTags, $tags);
}

$this->object['tags'] = $tags;
$this->object['tags'] = array_merge($this->object['tags'], $tags);

return $this;
}
Expand Down Expand Up @@ -453,10 +451,6 @@ public function alias(string $alias)

public function send()
{
if (config('opsgenie.tags')) {
$this->tags();
}

try {
$client = new Client();

Expand Down

0 comments on commit 7cf090c

Please sign in to comment.