<?php
	namespace Mocha\Oop\Methods;

	use Mocha\Core\KnownAttributeGuids;
	use Mocha\Core\KnownClassGuids;
	use Mocha\Core\KnownRelationshipGuids;
	use Mocha\Oop\Method;

	use Phast\UUID;

	class GetInstanceSetBySystemRoutineMethod
	{
		private $Method;
		public function __construct(Method $method)
		{
			$this->Method = $method;
		}

		public function execute(array $parms)
		{

			$instMethod = $this->Method->MethodInstance;
			$oms = $instMethod->OMS;

			$instSystemRoutine = $oms->getRelatedInstance($instMethod, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Get_Instance_Set_by_System_Routine_Method__uses__System_Instance_Set_Routine));
			$singular = false; // $oms->getAttributeValue($instSystemRoutine, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Singular));

			if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse("430f572dd1164b0497b265a9e9230ce5")))
			{
				// get User for User Name parm
				$userName = $parms["960FAF025C5940F791A720012A99D9ED"];
				$singular = true;
				
				if ($singular)
				{
					return $oms->getUserByUserName($userName);
				}
				return [ $oms->getUserByUserName($userName) ];
			}

			if ($singular)
			{
				return null;
			}
			return [ ];
		}
	}

?>