Skip to content

Commit

Permalink
Clear up the UserAgentParser->client
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPetterMG committed Aug 9, 2016
1 parent 17fd6cc commit 0591feb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Parser/Directives/UserAgentParser.php
Expand Up @@ -243,8 +243,9 @@ public function export()
*/
public function client($product = self::USER_AGENT, $version = null, $statusCode = null)
{
if (isset($this->client[$product . $version . $statusCode])) {
return $this->client[$product . $version . $statusCode];
$infix = $product . $version . $statusCode;
if (isset($this->client[$infix])) {
return $this->client[$infix];
}
$userAgentProduct = rtrim($product . '/' . $version, '/');
$userAgentMatch = $userAgentProduct;
Expand All @@ -255,10 +256,9 @@ public function client($product = self::USER_AGENT, $version = null, $statusCode
$userAgentMatch = self::USER_AGENT;
}
}
$client = new UserAgentClient($this->handler[$userAgentMatch], $this->base, $statusCode, $userAgentProduct);
$this->client = [
$product . $version . $statusCode => $client
];
return $client;
// Clear cache
$this->client = [];
// Cache and return
return $this->client[$infix] = new UserAgentClient($this->handler[$userAgentMatch], $this->base, $statusCode, $userAgentProduct);
}
}

0 comments on commit 0591feb

Please sign in to comment.