Create mock environment
@param  array $userData Array of custom environment keys and values
@return self
420189
public static function mock(array $userData = []): self
    {
        $data = \array_merge([
            'SERVER_PROTOCOL'      => 'HTTP/1.1',
            'REQUEST_METHOD'       => 'GET',
            'SCRIPT_NAME'          => '',
            'REQUEST_URI'          => '',
            'QUERY_STRING'         => '',
            'SERVER_NAME'          => 'localhost',
            'SERVER_PORT'          => 80,
            'HTTP_HOST'            => 'localhost',
            'HTTP_ACCEPT'          => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
            'HTTP_ACCEPT_CHARSET'  => 'utf-8;q=0.7,*;q=0.3',
            'HTTP_USER_AGENT'      => 'MY Framework',
            'REMOTE_ADDR'          => '127.0.0.1',
            'REQUEST_TIME'         => \time(),
            'REQUEST_TIME_FLOAT'   => \microtime(true),
        ], $userData);

        return new static($data);
    }
484344
public function unserialize($serializedData)
    {
        $repositoryData = json_decode($serializedData, true);
        $references     = $repositoryData['references'];

        foreach ($references as $name => $proxyReference) {
            $this->setReference(
                $name,
                $this->getManager()->getReference(
                    $proxyReference[0], // entity class name
                    $proxyReference[1]  // identifiers
                )
            );
        }

        $identities = $repositoryData['identities'];

        foreach ($identities as $name => $identity) {
            $this->setReferenceIdentity($name, $identity);
        }
    }
290849
public function impersonateUser($username, $validate = false)
    {
        return new UserContext($this->getConnection()->loginAs($username), $validate);
    }
216256
public static function createFromResponse($responseData)
    {
        $messageStatus = new self(null);
        $messageStatus->setRawResponseData($responseData)
            ->processResponse();

        if ($messageStatus['status'] !== 0 && $messageStatus['status'] !== '0') {
            throw new Exception($messageStatus['err_msg']);
        }

        //show message status instead of integer status code
        $messageStatus['message_status'] = self::$messageStatusType[$messageStatus['message_status']];

        return $messageStatus;
    }
832777
protected function createContextMatchingNodeData(NodeData $nodeData)
    {
        $nodePath = NodePaths::getRelativePathBetween(SiteService::SITES_ROOT_PATH, $nodeData->getPath());
        list($siteNodeName) = explode('/', $nodePath);
        $site = $this->_siteRepository->findOneByNodeName($siteNodeName);

        $contextProperties = [
            'workspaceName' => $nodeData->getWorkspace()->getName(),
            'invisibleContentShown' => true,
            'inaccessibleContentShown' => true,
            'removedContentShown' => true,
            'dimensions' => $nodeData->getDimensionValues(),
            'currentSite' => $site
        ];

        if ($site instanceof Site && $domain = $site->getFirstActiveDomain()) {
            $contextProperties['currentDomain'] = $domain;
        }

        return $this->_contextFactory->create($contextProperties);
    }
7448
public function instance($data)
    {
        $RagnarokUser = new SecUser();
        $this->userRagnarok = $RagnarokUser->populate($data);
        return $this->userRagnarok;
    }
107056
public function mapData($authData) {
		$map = $this->mapKeysToFields;
		list(, $model) = pluginSplit($this->_authenticateObject->settings['userModel']);
		$provider = Inflector::underscore($authData['provider']);
		$data = array($model => array($provider . '_credentials' => serialize($authData['credentials'])));

		foreach ($this->mapKeysToFields as $key => $path) {
			$map[$key] = String::insert($path, compact('model', 'provider'), array('after' => ':'));
			$value = Hash::get($authData, $key);
			$mappedKey = explode('.', $map[$key]);
			if (!empty($this->_user[array_pop($mappedKey)]) || empty($value)) {
				continue;
			}

			$data = Hash::insert($data, $map[$key], Hash::get($authData, $key));
		}

		return $data;
	}
304311
protected function create(array $data)
    {
        $user = UserModel::create($data);
        return User::find($user->id);
    }
143046
public function buildRequest($requestData)
    {
        $apiData       = $requestData->getApiData();
        $dynamicApiUrl = $requestData->getDynamicApiUrl();
        $apiKey        = $requestData->getApiKey();
        $requestMethod = empty($requestData->getRequestMethod()) ? 'POST' : $requestData->getRequestMethod();
        $apiUrl        = $this->getFullApiUrl($dynamicApiUrl);

        $headers    = (array)$requestData->getHeaders();
        $statusOnly = (bool)$requestData->getStatusOnly();

        $request = $this->requestFactory->create();
        $request->setApiData($apiData);
        $request->setApiUrl($apiUrl);
        $request->setApiKey($apiKey);
        $request->setRequestMethod($requestMethod);
        $request->setHeaders($headers);
        $request->setStatusOnly($statusOnly);
        return $request;
    }
1137242
public function createStorage($storageData)
    {
        if (!is_array($storageData)) {
            $errorMessage = 'Storage data needs to be array';
            throw new \InvalidArgumentException($errorMessage);
        }

        /* Should we check the required keys (storage, type) in the array? */

        return $this->create('/storage', $storageData);
    }
166079
private function set(array $postData)
    {
        return $this->putJson(sprintf(self::COMMUNITY_ENDPOINT . 'communities/%s', $this->id()), $postData);
    }
182329
public function getUser(array $userData): UserInterface
    {
        if (gettype($userData[ self::FIELD_ID ]) === 'string') {
            $userData[ self::FIELD_ID ] = Uuid::fromString($userData[ self::FIELD_ID ]);
        }

        if (gettype($userData[ self::FIELD_EMAIL ]) === 'string') {
            $userData[ self::FIELD_EMAIL ] = new Email($userData[ self::FIELD_EMAIL ]);
        }

        if (isset($userData[ self::FIELD_LAST_LOGIN ]) === false) {
            $userData[ self::FIELD_LAST_LOGIN ] = 'now';
        }

        return new User(
            $userData[ self::FIELD_ID ],
            $userData[ self::FIELD_EMAIL ],
            $userData[ self::FIELD_NAME ],
            new DateTime($userData[ self::FIELD_BIRTHDAY ]),
            new DateTime($userData[ self::FIELD_LAST_LOGIN ])
        );
    }
835816
public static function setPlatformAuthData(EntityAuthData $entityAuthData)
	{
		if(self::$_instance === NULL)
			throw new SonicRuntimeException('Sonic instance not initialized');
		
		self::$_instance->platformAuthData = $entityAuthData;
		
		return self::$_instance;
	}
666931
public static function setUserAuthData(EntityAuthData $entityAuthData)
	{
		if(self::$_instance === NULL)
			throw new SonicRuntimeException('Sonic instance not initialized');
		
		self::$_instance->userAuthData = $entityAuthData;
		
		self::$_instance->setContext(Sonic::CONTEXT_USER);
		
		return self::$_instance;
	}
1026616
public static function create(array $callbackData): self
    {
        $payload = $callbackData['payload'] ?? null;
        $referral = isset($callbackData['referral']) ? Referral::create($callbackData['referral']) : null;

        return new self($callbackData['title'], $payload, $referral);
    }
61960
public static function create(array $callbackData): self
    {
        $shippingAddress = Address::fromPayload($callbackData['shipping_address']);

        $contactEmail = $callbackData['contact_email'] ?? null;
        $contactPhone = $callbackData['contact_phone'] ?? null;

        return new self($shippingAddress, $callbackData['contact_name'], $contactEmail, $contactPhone);
    }
514771
public static function createFromKeyData(array $data): self
    {
        if (!\array_key_exists('keys', $data) || !\is_array($data['keys'])) {
            throw new \InvalidArgumentException('Invalid data.');
        }

        $keys = [];
        foreach ($data['keys'] as $key) {
            $jwk = JWK::create($key);
            if ($jwk->has('kid')) {
                $keys[$jwk->get('kid')] = $jwk;

                continue;
            }
            $keys[] = $jwk;
        }

        return new self($keys);
    }