HEX
Server: LiteSpeed
System: Linux s917.lon1.mysecurecloudhost.com 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: assibfaf (3034)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/assibfaf/public_html/prox-classes/Presenter/Profile/ProfileLazyArray.php
<?php 
/**
 * @package    Proxim
 * @author     Davison Pro <davis@davisonpro.dev | https://davisonpro.dev>
 * @copyright  2020 Proxim
 * @version    1.0
 * @since      File available since Release 1.0
*/

namespace Proxim\Presenter\Profile;

use Proxim\Presenter\AbstractLazyArray;
use Proxim\Application;
use Proxim\Configuration;
use Proxim\User\Customer;
use Proxim\Util\ArrayUtils;
use Proxim\Util\DateUtils;

class ProfileLazyArray extends AbstractLazyArray {
    /** @var Application */
    public $application;

    /** @var Customer */
    public $customer;

    /**
     * ProfileArray constructor.
     *
     * @throws AnnotationException
     * @throws ReflectionException
     */
    public function __construct(Customer $customer)
    {
        $this->application = Application::getInstance();
        $this->customer = $customer;

        parent::__construct();
    }

    /**
     * @arrayAccess
     *
     * @return int
     */
    public function getId()
    {
        return (int) $this->customer->id;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getGaUserId()
    {
        return (string) $this->customer->google_analytics_id;
    }

    /**
     * @arrayAccess
     *
     * @return bool
     */
    public function getHasPayments()
    {
        return (bool) $this->customer->total_spent > 0 ? true : false;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getEmail()
    {
        return (string) $this->customer->email;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getPhone()
    {
        return (string) $this->customer->phone;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getName()
    {
        return (string) $this->customer->name;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getSiteFullName()
    {
        return (string) Configuration::get('SITE_NAME');
    }

    /**
     * @arrayAccess
     *
     * @return bool
     */
    public function getIsTest()
    {
        return (bool) $this->customer->is_test;
    }

    /**
     * @arrayAccess
     *
     * @return bool
     */
    public function getIsSubscribed()
    {
        return (bool) $this->customer->is_subscribed;
    }

    /**
     * @arrayAccess
     *
     * @return bool
     */
    public function getPushNotificationsEnabled()
    {
        return (bool) $this->customer->push_notifications;
    }

    /**
     * @arrayAccess
     *
     * @return int
     */
    public function getLastAcademicLevel()
    {
        return (int) $this->customer->last_academic_level;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getAffiliateLink()
    {
        return Configuration::get('SITE_DOMAIN') . "/order?ref=" . $this->customer->id;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getLastPaymentMethod()
    {
        return (string) $this->customer->last_payment_method;
    }

    /**
     * @arrayAccess
     *
     * @return array
     */
    public function getCountry()
    {
        global $globals;

        $countries = ArrayUtils::get($globals, 'countries');
		$country_id = array_search($this->customer->country_id, array_column($countries, 'code'));
		$country_code = ArrayUtils::get(array_keys($countries), $country_id);
		$country = ArrayUtils::has($countries, $country_code) ? ArrayUtils::get($countries, $country_code) : array();
		
        return array(
            "id" => $country_code, 
            "name" => ArrayUtils::get($country, 'name'), 
            "code" => (int) ArrayUtils::get($country, 'code'), 
            "phoneCode" => (int) ArrayUtils::get($country, 'phoneCode')
        );
    }

    /**
     * @arrayAccess
     *
     * @return bool
     */
    public function getPrivacyOrTermsConfirmRequired()
    {
        return !$this->customer->policy_accepted ? true : false;
    }

    /**
     * @arrayAccess
     *
     * @return string
     */
    public function getPolicyAcceptedAt()
    {
        return $this->customer->policy_accepted ? DateUtils::convertToISOFormat($this->customer->policy_accepted) : null;
    }

    /**
     * @arrayAccess
     *
     * @return bool
     */
    public function getHasPersonalData()
    {
        return $this->customer->email ? true : false;
    }

    /**
     * @arrayAccess
     *
     * @return bool
     */
    public function getSurveyBannerLink()
    {
        return false;
    }
}