public function get(?string $key = null)
    {
        $key = $this->constructKey($key);

        if (is_null($key)) {
            $array = $this->toArray();

            return $this->count() == 1 ? end($array) : $array;
        }

        return $this->parseKey($key, function ($part, $result) {
            if (isset($result[$part])) {
                return $result[$part];
            }
        });
    }
public function get(?string $key = null)
    {
        $key = $this->constructKey($key);

        if (is_null($key)) {
            $array = $this->toArray();

            return $this->count() == 1 ? end($array) : $array;
        }

        return $this->parseKey($key, function ($part, $result) {
            if (isset($result[$part])) {
                return $result[$part];
            }
        });
    }
public function get ( ? string $ key = null ) { $ key = $ this -> constructKey ( $ key ) ; if ( is_null ( $ key ) ) { $ array = $ this -> toArray ( ) ; return $ this -> count ( ) == 1 ? end ( $ array ) : $ array ; } return $ this -> parseKey ( $ key , function ( $ part , $ result ) { if ( isset ( $ result [ $ part ] ) ) { return $ result [ $ part ] ; } } ) ; }
Gets data by using key with dotted notation.

@param string|null $key

@return mixed
Gets data by using key with dotted notation .