public function evaluateEntityInstanceFactory(array $factory)
    {
        if (!isset($factory['class'])) {
            throw new InvalidArgumentException();
        }

        $factoryReference = $factory['class'];

        $factoryMethod = isset($factory['method'])
            ? $factory['method']
            : $this->defaultFactoryMethod;

        $factoryStatic = isset($factory['static'])
            ? (bool) $factory['static']
            : (bool) $this->defaultFactoryStatic;

        $factory = class_exists($factoryReference)
            ? (
            $factoryStatic
                ? $factoryReference
                : new $factoryReference()
            )
            : $this
                ->container
                ->get($factoryReference);

        return $factoryStatic
            ? $factory::$factoryMethod()
            : $factory->$factoryMethod();
    }