protected function updateComposerJson(array $requires, array $devRequires, int $type): void
    {
        $this->io->writeError('Updating composer.json');

        if ($type === self::ADD) {
            $jsonManipulator = new JsonManipulator(\file_get_contents($this->jsonFile->getPath()));
            $sortPackages    = $this->composer->getConfig()->get('sort-packages') ?? false;

            foreach ($requires as $name => $version) {
                $jsonManipulator->addLink('require', $name, $version, $sortPackages);
            }

            foreach ($devRequires as $name => $version) {
                $jsonManipulator->addLink('require-dev', $name, $version, $sortPackages);
            }

            \file_put_contents($this->jsonFile->getPath(), $jsonManipulator->getContents());
        } elseif ($type === self::REMOVE) {
            $jsonFileContent = $this->jsonFile->read();

            foreach ($requires as $packageName => $version) {
                unset($jsonFileContent['require'][$packageName]);
            }

            foreach ($devRequires as $packageName => $version) {
                unset($jsonFileContent['require-dev'][$packageName]);
            }

            $this->jsonFile->write($jsonFileContent);
        }
    }