<?php

	namespace Icing\Policy;

	use Authorization\Policy\ResolverInterface;
	use Authorization\Policy\Exception\MissingPolicyException;
	use Cake\Controller\Controller;

	class ControllerResolver implements ResolverInterface
	{
		public function getPolicy($resource): ControllerHookPolicy
        {
			if ($resource instanceof Controller/* && method_exists($resource, 'isAuthorized')*/) {
				return new ControllerHookPolicy();
			}

			if (is_scalar($resource)) {
				$resource = "Policy for '$resource' has not been defined.";
			}
			throw new MissingPolicyException($resource);
		}
	}
