public function checkText(EncodingAwareSource $source, array $languages): array
    {
        $process = $this->createProcess($this->createArguments($source, $languages));
        $process->setEnv($this->createEnvVars($source, $languages));

        $process->setInput($source->getAsString());

        try {
            $process->run();
        } catch (RuntimeException $e) {
            throw new ExternalProgramFailedException(
                $process->getCommandLine(),
                $e->getMessage(),
                0,
                $e
            );
        }

        try {
            $exitCode = $process->getExitCode();
        } catch (RuntimeException $e) {
            throw new EnvironmentException($e->getMessage(), $e->getCode(), $e);
        }

        if (0 !== $exitCode) {
            throw new ExternalProgramFailedException(
                $process->getCommandLine(),
                $process->getErrorOutput() ?: $process->getOutput(),
                $exitCode
            );
        }

        $output = $process->getOutput();

        if ($source instanceof EncodingAwareSource
            && strcasecmp($source->getEncoding(), 'UTF-8') !== 0
        ) {
            $output = iconv($source->getEncoding(), 'UTF-8', $output);
        }

        return $this->parseOutput($output);
    }