You are here

public static function Condition::getProperty in Apigee Edge 8

Gets a property from an object.

To do this, the function tries to guess the name of the getter.

Parameters

object $item: Source object.

string $property: Property name.

Return value

mixed|null Property value or NULL if not found.

2 calls to Condition::getProperty()
Condition::matchProperty in src/Entity/Query/Condition.php
Creates a filter closure that matches a property.
Query::execute in src/Entity/Query/Query.php
Execute the query.

File

src/Entity/Query/Condition.php, line 195

Class

Condition
Defines the condition class for the Apigee Edge entity query.

Namespace

Drupal\apigee_edge\Entity\Query

Code

public static function getProperty($item, string $property) {
  $normalized = ucfirst(implode('', array_map('ucfirst', explode('_', $property))));
  $getter_candidates = [
    "is{$normalized}",
    "get{$normalized}",
    $normalized,
  ];
  foreach ($getter_candidates as $getter) {
    if (method_exists($item, $getter)) {
      return call_user_func([
        $item,
        $getter,
      ]);
    }
  }
  return NULL;
}