protected function wrapAndRecurse($path, $data) { // strict comparison is very important as PHP casts zero // and '0' to false, and at the same time, arrays are zero based // which means that a path like "helloworld.0" would be considered // as simply "helloworld" if ($path === '') { return $data; } // more hops to go, so we recurse $source = DataSource::make($data); return $source[$path]; }