Commit 65285097 authored by Guy Thouret's avatar Guy Thouret

Add phpdocs and move referral cookie instantiation to constructor - #1077

1 merge request!413Extract record view details from analytics/views api call
Pipeline #101844703 passed with stages
in 7 minutes and 7 seconds
......@@ -7,10 +7,16 @@ use Minds\Core\Di\Di;
use Minds\Entities;
use Minds\Helpers\Counters;
/**
* Class Record
* @package Minds\Core\Analytics\Views
*/
class Record
{
/** @var Manager */
protected $manager;
/** @var Core\Referrals\ReferralCookie $referralCookie */
protected $referralCookie;
/** @var string $lastError */
protected $lastError = '';
/** @var array $boostData */
......@@ -20,33 +26,55 @@ class Record
/** @var array $clientMeta */
protected $clientMeta;
public function __construct(Manager $manager=null)
public function __construct(Manager $manager=null, Core\Referrals\ReferralCookie $referralCookie=null)
{
$this->manager = $manager ?: new Manager();
$this->referralCookie = $referralCookie ?: Di::_()->get('Referrals\Cookie');
}
/**
* Set the client meta
* @param array $clientMeta
* @return $this
*/
public function setClientMeta(array $clientMeta): self
{
$this->clientMeta = $clientMeta;
return $this;
}
/**
* Set the identifier
* @param string $identifier
* @return $this
*/
public function setIdentifier(string $identifier): self
{
$this->identifier = $identifier;
return $this;
}
/**
* Get boost impressions data
* @return array
*/
public function getBoostImpressionsData(): array
{
return $this->boostData;
}
/**
* @return string
*/
public function getLastError(): string
{
return $this->lastError;
}
/**
* Record a boost
* @return bool
*/
public function recordBoost(): bool
{
/** @var Core\Boost\Network\Expire $expire */
......@@ -93,6 +121,10 @@ class Record
return true;
}
/**
* Record an entity
* @return bool
*/
public function recordEntity(): bool
{
$entity = Entities\Factory::build($this->identifier);
......@@ -141,10 +173,7 @@ class Record
error_log($e);
}
Di::_()->get('Referrals\Cookie')
->setEntity($entity)
->create();
$this->referralCookie->setEntity($entity)->create();
return true;
}
}
Please register or to comment