<?php

namespace Application\Service\Extension\Helper;

use Application\Service\Extension\Helper\base\BaseUserHelper;
use Application\Service\Extension\Laminas;

class UserHelper extends BaseUserHelper
{
    protected function getCacheKey()
    {
        return self::class;
    }

    protected function __getUserData()
    {
        if (!$this->getCache()) {
            $data = Laminas::$serviceManager->adminUser->fetchOne(['where' => ['id' => $this->userId]]);
            $this->setCache($data);
        }

        return $this->getCache();
    }

    public function getUserName(string $default = 'System')
    {
        return $this->__getUserData()['realname'] ?? $default;
    }
}