Convert the npm licenses list.

@param array|string $licenses The npm package licenses list

@return array|string
195490
public static function convertLicenses($licenses)
    {
        if (!\is_array($licenses)) {
            return $licenses;
        }

        $result = array();
        foreach ($licenses as $license) {
            if (\is_array($license)) {
                if (!empty($license['type'])) {
                    $result[] = $license['type'];
                } elseif (!empty($license['name'])) {
                    $result[] = $license['name'];
                }
            } else {
                $result[] = $license;
            }
        }

        return $result;
    }
1157716
public function getLicense() : ?int 
    {
        if ( ! $this->hasLicense()) {
            $this->setLicense($this->getDefaultLicense());
        }
        return $this->license;
    }
360915
public function setLicense(array $license)
    {
        if (!array_key_exists('name', $license) || !array_key_exists('key', $license)) {
            throw new Exception\InvalidArgumentException(__METHOD__ . " In order to set a libxl license you must provide an associative array with 'name' and 'key' set.");
        }
        $this->license = $license;
    }
778328
public function getAll(array $queryParams = [])
    {
        $response = $this->api->licenses()->getAll($queryParams);

        return new LicensesResponse($response);
    }
652747
function has_premium_license( $licenses ) {
			if ( is_array( $licenses ) ) {
				/**
				 * @var FS_Plugin_License[] $licenses
				 */
				foreach ( $licenses as $license ) {
					if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
						return true;
					}
				}
			}

			return false;
		}
373697
def normalize_licenses(licenses)
      standard_licenses = Array.wrap(licenses).map { |l| URI.parse(l["url"]) }.select { |li| li.host && li.host[/(creativecommons.org|opensource.org)$/] }
      return licenses unless standard_licenses.present?

      # use HTTPS
      uri.scheme = "https"

      # use host name without subdomain
      uri.host = Array(/(creativecommons.org|opensource.org)/.match uri.host).last

      # normalize URLs
      if uri.host == "creativecommons.org"
        uri.path = uri.path.split('/')[0..-2].join("/") if uri.path.split('/').last == "legalcode"
        uri.path << '/' unless uri.path.end_with?('/')
      else
        uri.path = uri.path.gsub(/(-license|\.php|\.html)/, '')
        uri.path = uri.path.sub(/(mit|afl|apl|osl|gpl|ecl)/) { |match| match.upcase }
        uri.path = uri.path.sub(/(artistic|apache)/) { |match| match.titleize }
        uri.path = uri.path.sub(/([^0-9\-]+)(-)?([1-9])?(\.)?([0-9])?$/) do
          m = Regexp.last_match
          text = m[1]

          if m[3].present?
            version = [m[3], m[5].presence || "0"].join(".")
            [text, version].join("-")
          else
            text
          end
        end
      end

      uri.to_s
    rescue URI::InvalidURIError
      nil
    end
672919
private function fetch_license_by_key( $license_id, $license_key ) {
            $this->_logger->entrance();

            $api = $this->get_current_or_network_user_api_scope();

            $result = $api->get( "/licenses/{$license_id}.json?license_key=" . urlencode( $license_key ) );

            return $this->is_api_result_entity( $result ) ?
                new FS_Plugin_License( $result ) :
                $result;
        }
132325
def _split_license(license):
    ''''''
    return (x.strip() for x in (l for l in _regex.split(license) if l))
633654
public function validate( $license ) {
		try {
			$url      = untrailingslashit( home_url( '' ) );
			$guid     = $this->guid;
			$response = wp_remote_post( $this->validate_url, [
				'body' => [
					'license' => $license,
					'url'     => $url,
				],
			] );
			if ( is_wp_error( $response ) ) {
				return $response;
			}
			if ( 200 === $response['response']['code'] ) {
				return true;
			} else {
				$body = json_decode( $response['body'] );
				return new \WP_Error( $response['response']['code'], $body->message );
			}
		} catch ( \Exception $e ) {
			return new \WP_Error( $e->getCode(), $e->getMessage() );
		}
	}
123978
protected function getPackages(array $vendors)
    {
        $packagist = new Packagist();

        $client = new Client($packagist);

        $packages = $client->packages($vendors);

        return new PackagesPresenter($packages);
    }
1028286
public List<License> getLicenses() {
        final ModelMapper modelMapper = new ModelMapper(repoHandler);
        final List<License> licenses = new ArrayList<>();
        for (final DbLicense dbLicense : licensesRegexp.values()) {
            licenses.add(modelMapper.getLicense(dbLicense));
        }
        return licenses;
    }
1095573
static public function enable($license) {
        global $DB;
        if ($license = self::get_license_by_shortname($license)) {
            $license->enabled = 1;
            $DB->update_record('license', $license);
        }
        self::set_active_licenses();
        return true;
    }
496989
public static function get($slug = null)
    {
        $licenses = self::getLicenseFile();
        $data = (array)$licenses->content();
        $licenses->free();
        $slug = strtolower($slug);

        if (!$slug) {
            return $data['licenses'] ?? [];
        }

        return $data['licenses'][$slug] ?? '';
    }
355578
def list_licenses(service_instance=None):
    '''
    
    '''
    log.trace('Retrieving all licenses')
    licenses = salt.utils.vmware.get_licenses(service_instance)
    ret_dict = [{'key': l.licenseKey,
                 'name': l.name,
                 'description': l.labels[0].value if l.labels else None,
                 # VMware handles unlimited capacity as 0
                 'capacity': l.total if l.total > 0 else sys.maxsize,
                 'used': l.used if l.used else 0}
                 for l in licenses]
    return ret_dict
359995
private function getVersionNumbers(array $versions): array
    {
        $versionNumbers = array_column($versions, 'versionNo');

        return array_combine($versionNumbers, array_fill_keys($versionNumbers, false));
    }
638724
function _get_license_by_id( $id, $sync_licenses = true ) {
            $this->_logger->entrance();

            if ( ! FS_Plugin_License::is_valid_id( $id ) ) {
                return false;
            }

            /**
             * When running from the network level admin and opted-in from the network,
             * check if the license exists in the network user licenses collection.
             *
             * @author Vova Feldman (@svovaf)
             * @since  2.0.0
             */
            if ( fs_is_network_admin() &&
                 $this->is_network_registered() &&
                 ( ! is_object( $this->_user ) || $this->_storage->network_user_id != $this->_user->id )
            ) {
                $licenses = $this->get_user_licenses( $this->_storage->network_user_id );

                foreach ( $licenses as $license ) {
                    if ( $id == $license->id ) {
                        return $license;
                    }
                }
            }

            if ( ! $this->has_any_license() && $sync_licenses ) {
                $this->_sync_licenses( $id );
            }

            if ( is_array( $this->_licenses ) ) {
                foreach ( $this->_licenses as $license ) {
                    if ( $id == $license->id ) {
                        return $license;
                    }
                }
            }

            return false;
        }
1217977
public static function getConfiguredPackage()
    {
        $package = new Package;
        $package->setLicense(user_config('configuration.license'));
        $package->setAuthors(user_config('configuration.authors'));

        return $package;
    }