src/Neuron/Net/Entity.php
public function setFromData ($data)
	{
		// Check signature
		$model = $this;

		$chk = self::CHECK_SIGNATURE;

		if ($chk && !isset ($data['signature']))
		{
			throw new InvalidParameter ("All decoded requests must have a signature.");
		}

		if ($chk && $data['signature'] != self::calculateSignature ($data))
		{
			throw new InvalidParameter ("Leave now, and Never come Back! *gollem, gollem* (Decoded request signature mismatch).");
		}

		// The body. If data is found, body is not used.
		if (isset ($data['data']) && !empty ($data['data']))
		{
			$model->setData ($data['data']);
		}

		else if (isset ($data['body']))
		{
			$model->setBody ($data['body']);
		}

		if (isset ($data['headers']))
		{
			$model->setHeaders ($data['headers']);
		}

		if (isset ($data['cookies']))
		{
			$model->setCookies ($data['cookies']);
		}

		if (isset ($data['post']))
		{
			$model->setPost ($data['post']);
		}

		if (isset ($data['status']))
		{
			$model->setStatus ($data['status']);
		}

		return $model;
	}
public function setFromData ($data)
	{
		// Check signature
		$model = $this;

		$chk = self::CHECK_SIGNATURE;

		if ($chk && !isset ($data['signature']))
		{
			throw new InvalidParameter ("All decoded requests must have a signature.");
		}

		if ($chk && $data['signature'] != self::calculateSignature ($data))
		{
			throw new InvalidParameter ("Leave now, and Never come Back! *gollem, gollem* (Decoded request signature mismatch).");
		}

		// The body. If data is found, body is not used.
		if (isset ($data['data']) && !empty ($data['data']))
		{
			$model->setData ($data['data']);
		}

		else if (isset ($data['body']))
		{
			$model->setBody ($data['body']);
		}

		if (isset ($data['headers']))
		{
			$model->setHeaders ($data['headers']);
		}

		if (isset ($data['cookies']))
		{
			$model->setCookies ($data['cookies']);
		}

		if (isset ($data['post']))
		{
			$model->setPost ($data['post']);
		}

		if (isset ($data['status']))
		{
			$model->setStatus ($data['status']);
		}

		return $model;
	}
public function setFromData ( $ data ) { // Check signature $ model = $ this ; $ chk = self :: CHECK_SIGNATURE ; if ( $ chk && ! isset ( $ data [ 'signature' ] ) ) { throw new InvalidParameter ( "All decoded requests must have a signature." ) ; } if ( $ chk && $ data [ 'signature' ] != self :: calculateSignature ( $ data ) ) { throw new InvalidParameter ( "Leave now, and Never come Back! *gollem, gollem* (Decoded request signature mismatch)." ) ; } // The body. If data is found, body is not used. if ( isset ( $ data [ 'data' ] ) && ! empty ( $ data [ 'data' ] ) ) { $ model -> setData ( $ data [ 'data' ] ) ; } else if ( isset ( $ data [ 'body' ] ) ) { $ model -> setBody ( $ data [ 'body' ] ) ; } if ( isset ( $ data [ 'headers' ] ) ) { $ model -> setHeaders ( $ data [ 'headers' ] ) ; } if ( isset ( $ data [ 'cookies' ] ) ) { $ model -> setCookies ( $ data [ 'cookies' ] ) ; } if ( isset ( $ data [ 'post' ] ) ) { $ model -> setPost ( $ data [ 'post' ] ) ; } if ( isset ( $ data [ 'status' ] ) ) { $ model -> setStatus ( $ data [ 'status' ] ) ; } return $ model ; }
Serialize & deserialize requests
@param $data
@return \Neuron\Net\Request
@throws \Neuron\Exceptions\InvalidParameter
Serialize & deserialize requests