You are here

public static function Link::compare in JSON:API 8.2

Compares two links by their href.

Parameters

\Drupal\jsonapi\JsonApiResource\Link $a: The first link.

\Drupal\jsonapi\JsonApiResource\Link $b: The second link.

Return value

int The result of strcmp() on the links' hrefs.

2 calls to Link::compare()
Link::merge in src/JsonApiResource/Link.php
Merges two link objects' relation types and target attributes.
LinkCollection::withLink in src/JsonApiResource/LinkCollection.php
Gets a new LinkCollection with the given link inserted.

File

src/JsonApiResource/Link.php, line 142

Class

Link
Represents an RFC8288 based link.

Namespace

Drupal\jsonapi\JsonApiResource

Code

public static function compare(Link $a, Link $b) {
  return strcmp($a
    ->getHref(), $b
    ->getHref());
}