Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio-Emmolo authored and github-actions[bot] committed Aug 30, 2023
1 parent 4e594d6 commit a2bfd7e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/ReferralRewriterTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

class ReferralRewriterTag
{

protected ?string $link;

protected ?string $tag;

protected ?string $subtag;

protected ?string $additionalQuery;

/**
* Start function
*/
public function rewrite(string $link, ?string $tag, ?string $subtag, ?string $additionalQuery = null): string
public function rewrite(string $link, ?string $tag, ?string $subtag, string $additionalQuery = null): string
{
$this->link = $link;
$this->tag = $tag;
Expand All @@ -39,20 +41,19 @@ public function rewriteAmazonLink(): string
/**
* Rewrite instant gaming link with tag and subtag
*/
public function rewriteInstantGamingLink() : string
{
public function rewriteInstantGamingLink(): string
{
return $this->rewriteLink(tagKey: 'igr', subTagKey: 'igr_extra');
}
}

/**
* Rewrite ebay link with tag and subtag
*/
public function rewriteEbayLink() : string
public function rewriteEbayLink(): string
{
return $this->rewriteLink(tagKey: 'campid', subTagKey: 'customid');
}


/**
* Retrieve the domain type
*/
Expand All @@ -77,15 +78,16 @@ public function rewriteLink(string $tagKey, string $subTagKey): string|array|nul
parse_str($urlComponents['query'], $queryParams);
}

if($this->tag){
if ($this->tag) {
$queryParams[$tagKey] = $this->tag;
}

if($this->subtag){
if ($this->subtag) {
$queryParams[$subTagKey] = $this->subtag;
}

$newQueryParams = http_build_query($queryParams);
return $urlComponents['scheme'] . '://' . $urlComponents['host'] . $urlComponents['path'] . '?' . $newQueryParams . $this->additionalQuery;

return $urlComponents['scheme'].'://'.$urlComponents['host'].$urlComponents['path'].'?'.$newQueryParams.$this->additionalQuery;
}
}

0 comments on commit a2bfd7e

Please sign in to comment.