public function produced(
        $keyOrValue = null,
        $value = null
    ): ?EventCollection {
        $cardinality = $this->cardinality;
        $argumentCount = func_num_args();

        if (0 === $argumentCount) {
            $key = null;
            $arguments = [];
        } elseif (1 === $argumentCount) {
            $key = null;
            $value = $this->matcherFactory->adapt($keyOrValue);
            $arguments = [$value];
        } else {
            $key = $this->matcherFactory->adapt($keyOrValue);
            $value = $this->matcherFactory->adapt($value);
            $arguments = [$key, $value];
        }

        if ($result = $this->checkProduced(...$arguments)) {
            return $result;
        }

        return $this->assertionRecorder->createFailure(
            $this->assertionRenderer->renderIterableProduced(
                $this->subject,
                $cardinality,
                $this->isGenerator,
                $key,
                $value
            )
        );
    }