<?php
	namespace Mocha\Oop;

	use Mocha\Core\KnownAttributeGuids;
	use Mocha\Core\KnownInstanceGuids;
	use Mocha\Core\KnownRelationshipGuids;
	use Mocha\Oms\Oms;
	use Mocha\Core\InstanceReference;
	
	use Mocha\Oop\Methods\GetInstanceSetBySystemRoutineMethod;

	class Method
	{
		public InstanceReference $MethodInstance;

		public function __construct(InstanceReference $methodInstance)
		{
			$this->MethodInstance = $methodInstance;
		}

		public function execute(array $parms) : null|array|InstanceReference
		{
			$oms = $this->MethodInstance->OMS;

			$methods = array
			(
				65 => new GetInstanceSetBySystemRoutineMethod($this)
			);


			echo ($oms->getAttributeValue($this->MethodInstance, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Name)));

			$parentClass = $oms->getParentClass($this->MethodInstance);
			if (array_key_exists($parentClass->InstanceKey->InstanceIndex, $methods))
			{
				$method = $methods[$parentClass->InstanceKey->InstanceIndex];
				return $method->execute($parms);
			}
			else
			{
				echo ("method implementation not found for method 1\$" . $parentClass->InstanceKey->InstanceIndex . " !");
			}
			return null;
		}
	}
?>