title: How can I safely retrieve this property of this object?
body: <p>I have a Stripe subscription object that looks like this...</p>
  
  <pre><code>subscription: {
      items: {
          data: [
              plan: {
                  id: 'my_plan_id'
              }
          ]
      }
  }
  </code></pre>
  
  <p>What's the best way to safely retrieve the plan id? Currently I am doing the following.</p>
  
  <pre><code>'plan_id' =&gt; $subscription-&gt;items-&gt;data[0]-&gt;plan-&gt;id,
  </code></pre>
  
  <p>But, it looks like that will fail if <code>items</code>, <code>data[0]</code>, or <code>plan</code>, is not set. I could do nest if statements like, <code>if (isset($subscription-&gt;items) &amp;&amp; isset(data[0]) ...</code>, but I am not sure that is the best way. </p>
  
  <p>Is there a PHP method or Laravel method that I can use to extract that property safely that would be cleaner than that? </p>