How to take a specific value?

Asked

Viewed 197 times

0

When giving VAR_DUMP in a variable, comes the result

object(PagarMe\Sdk\Transaction\BoletoTransaction)#28 (33) {   ["boletoUrl":protected]=>   string(61) "https://api.pagar.me/1/boletos/live_cjcj73jk20fqvon3ceav0x7g1"   ["boletoBarcode":protected]=>   string(54) "23791.22928 50001.160386
25000.046901 4 74100000016620"   ["boletoExpirationDate":protected]=>   object(DateTime)#39 (3) {
    ["date"]=>
    string(26) "2018-01-20 02:00:00.000000"
    ["timezone_type"]=>
    int(2)
    ["timezone"]=>
    string(1) "Z"   }   ["async":protected]=>   NULL   ["boletoInstructions":protected]=>   NULL   ["id":protected]=>   int(31470262)   ["status":protected]=>   string(15) "waiting_payment"  ["refuseReason":protected]=>   NULL   ["statusReason":protected]=>   string(8) "acquirer"   ["acquirerName":protected]=>   string(7) "pagarme"   ["acquirerResponseCode":protected]=>   NULL   ["authorizationCode":protected]=>   NULL   ["softDescriptor":protected]=>   NULL   ["tid":protected]=>   int(31470262)   ["nsu":protected]=>   int(31470262)   ["dateCreated":protected]=>   object(DateTime)#40 (3) {
    ["date"]=>
    string(26) "2018-01-17 15:01:23.628000"
    ["timezone_type"]=>
    int(2)
    ["timezone"]=>
    string(1) "Z"   }   ["dateUpdated":protected]=>   object(DateTime)#41 (3) {
    ["date"]=>
    string(26) "2018-01-17 15:01:26.025000"
    ["timezone_type"]=>
    int(2)
    ["timezone"]=>
    string(1) "Z"   }   ["amount":protected]=>   int(16620)   ["cost":protected]=>   int(0)   ["postbackUrl":protected]=>   string(77) "https://www.idealnutri.com/magnesio-dimalato/pagarme/postback.php?valor=16620" ["paymentMethod":protected]=>   string(6) "boleto"   ["antifraudScore":protected]=>   NULL   ["referer":protected]=>   string(14) "encryption_key"   ["ip":protected]=>   string(14) "187.22.118.132"   ["subscriptionId":protected]=>   NULL   ["phone":protected]=>   NULL   ["address":protected]=>   NULL   ["customer":protected]=>   object(stdClass)#43 (15) {
    ["object"]=>
    string(8) "customer"
    ["id"]=>
    int(12706533)
    ["external_id"]=>
    string(5) "72660"
    ["type"]=>
    string(10) "individual"
    ["country"]=>
    string(2) "br"
    ["document_number"]=>
    NULL
    ["document_type"]=>
    string(3) "cpf"
    ["name"]=>
    string(14) "Deyvison Silva"
    ["email"]=>
    string(22) "[email protected]"
    ["phone_numbers"]=>
    array(1) {
      [0]=>
      string(14) "+5511888889999"
    }
    ["born_at"]=>
    NULL
    ["birthday"]=>
    NULL
    ["gender"]=>
    NULL
    ["date_created"]=>
    string(24) "2018-01-17T15:01:23.591Z"
    ["documents"]=>
    array(1) {
      [0]=>
      object(stdClass)#46 (4) {
        ["object"]=>
        string(8) "document"
        ["id"]=>
        string(29) "doc_cjcj73hua0krj2h647v36s1m6"
        ["type"]=>
        string(3) "cpf"
        ["number"]=>
        string(11) "11292867701"
      }
    }   }   ["metadata":protected]=>   array(0) {   }   ["paidAmount":protected]=>   int(0)   ["refundedAmount":protected]=>   int(0)   ["splitRules":protected]=>   NULL   ["token":protected]=>   NULL }

I want to take only the value below, as I do?

["boletoUrl":protected]=> string(61) "https://api.pagar.me/1/boletos/live_cjcj73jk20fqvon3ceav0x7g1]
  • How is a property protected would have to have some method to return the value, example: getBoletoUrl(). But for this to work this method must exist in the class.

  • The value of boletoUrl is https://api.pagar.me/1/boletos/live_cjcj73jk20fqvon3ceav0x7g1.... this appearing in var_dump

  • To take that amount you’d have to do $url = $seu_objeto->boletoUrl;, but as property boletoUrl is protected this line will return you a Fatal Error.

  • http://php.net/manual/en/language.oop5.visibility.php

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.