| Server IP : 123.56.80.60 / Your IP : 216.73.216.78 Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/site/20241224/spunner/wp-content/plugins/wp-statistics/src/Decorators/ |
Upload File : |
<?php
namespace WP_Statistics\Decorators;
use WP_Statistics\Service\Analytics\Referrals\SourceChannels;
use WP_Statistics\Utils\Url;
class ReferralDecorator
{
private $item;
public function __construct($item)
{
$this->item = $item;
}
/**
* Get the raw referrer value.
*
* @return string|null
*/
public function getRawReferrer()
{
return $this->item->referred ?? null;
}
/**
* Get the referrer url.
*
* @return string|null
*/
public function getReferrer()
{
return $this->item->referred ? Url::formatUrl($this->item->referred) : null;
}
/**
* Get the source channel (e.g., direct, search, etc.).
*
* @return string|null
*/
public function getSourceChannel()
{
return SourceChannels::getName($this->item->source_channel) ?? null;
}
/**
* Get the source name (e.g., Google, Yandex, etc.).
*
* @return string|null
*/
public function getSourceName()
{
return $this->item->source_name ?? null;
}
/**
* Get the total number of referrals.
*
* @return int
*/
public function getTotalReferrals()
{
return $this->item->visitors ? number_format_i18n($this->item->visitors) : 0;
}
}