Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. JsonManipulator.php

function JsonManipulator::removeMainKeyIfEmpty

File

vendor/composer/composer/src/Composer/Json/JsonManipulator.php, line 533

Class

JsonManipulator
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Json

Code

public function removeMainKeyIfEmpty(string $key) : bool {
    $decoded = JsonFile::parseJson($this->contents);
    if (!array_key_exists($key, $decoded)) {
        return true;
    }
    if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
        return $this->removeMainKey($key);
    }
    return true;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal