public function validateContract($class, $contract)
    {
        $validateObject = function ($object) {
            //does need trigger when calling *_exists with object
            $condition = is_string($object) ? class_exists($object) || interface_exists($object) : is_object($object);
            if (false === $condition) {
                $this->throwException(new \InvalidArgumentException('Class not exists ' . $object));
            }
        };

        $convertClassToString = function ($object) {
            if (is_object($object)) {
                $object = get_class($object);
            }

            return is_string($object) ? $object : false;
        };

        $validateObject($class);
        $validateObject($contract);

        if (!($class instanceof $contract)) {

            if (is_object($class)) {
                $class = get_class($class);
            }
            $this->throwException(new \LogicException($convertClassToString($class) . ' needs to be an instance of ' . $convertClassToString($contract)));
        }

        return $class;
    }