0

this is var_dump for my object

object(HapiClient\Hal\Resource)[25]
  private 'state' => 
    array (size=5)
      'reference' => string '7498ff04-240c-11e6-9f09-000000000000' (length=36)
      'state' => string 'open.running' (length=12)
      'started' => boolean true
      'dateCreated' => string '2016-05-27T13:10:59.589+0000' (length=28)
      'paymentScheme' => string 'SEPA.DIRECT_DEBIT.CORE' (length=22)
  private 'links' => 
    array (size=6)
      'self' => 
        object(HapiClient\Hal\Link)[59]
          private 'href' => string 'INFORMATION' (length=94)
          private 'templated' => null

...

all of this = $res;

how to get access to this :

private 'href' => string 'INFORMATION' (length=94)

OR

 'state' => string 'open.running' (length=12)
2
  • the only way to access to a private propriety outside the class is with Reflection Commented May 27, 2016 at 13:21
  • @Federico - or by using methods provided by the class itself Commented May 27, 2016 at 13:23

1 Answer 1

2

That package provides some public accessor methods, as described here: https://github.com/SlimPay/hapiclient-php/tree/master/src/Hal

In your case, to access the "state", you would use

$state = $res->getState()['state'];

and to get the "href" you would use

$href = $res->getLink('self')->getHref();
Sign up to request clarification or add additional context in comments.

1 Comment

you mean getState and getLink('self')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.