<?php
namespace Illuminate\Support;
use ArrayAccess;
use ArrayObject;
use Illuminate\Support\Traits\Macroable;
class Optional implements ArrayAccess
{
use Macroable {
__call as macroCall;
}
protected $value;
public function __construct($value)
{
$this->value = $value;
}
public function __get($key)
{
if (is_object($this->value)) {
return $this->value->{$key} ?? null;
}
}