Overview

Namespaces

  • None
  • Peridot
    • Leo
      • Formatter
      • Interfaces
        • Assert
      • Matcher
        • Template
      • ObjectPath
      • Responder
  • PHP

Classes

  • ObjectPath
  • ObjectPathValue
  • Overview
  • Namespace
  • Class
  • Tree

Class ObjectPath

ObjectPath is a utility for parsing object and array strings into ObjectPathValues.

Namespace: Peridot\Leo\ObjectPath
Package: Peridot\Leo\Utility
Located at ObjectPath/ObjectPath.php
Methods summary
public
# __construct( array|object $subject )

Parameters

$subject
public Peridot\Leo\ObjectPath\ObjectPathValue
# get( string $path )

Returns an ObjectPathValue if the property described by $path can be located in the subject.

Returns an ObjectPathValue if the property described by $path can be located in the subject.

A path expression uses object and array syntax.

Parameters

$path

Returns

Peridot\Leo\ObjectPath\ObjectPathValue

Code

$person = new stdClass(); $person->name = new stdClass(); $person->name->first = 'brian'; $person->name->last = 'scaturro'; $person->hobbies = ['programming', 'reading', 'board games'];

$path = new ObjectPath($person); $first = $path->get('name->first'); $reading = $path->get('hobbies[0]');


Endcode

public array
# getPathParts( mixed $path )

Breaks a path expression into an array used for navigating a path.

Breaks a path expression into an array used for navigating a path.

Parameters

$path

Returns

array
protected array
# getPropertyCollection( mixed $subject )

Returns a property as an array.

Returns a property as an array.

Parameters

$subject

Returns

array
protected mixed
# normalizeKey( mixed $key )

Return a key that can be used on the current subject.

Return a key that can be used on the current subject.

Parameters

$key

Returns

mixed
Properties summary
protected array|object $subject

The subject to match path expressions against.

The subject to match path expressions against.

#
Leo API documentation generated by ApiGen