/**
  * Checks if $key exists in current array as index. If it exists, true is returned.
  * If the $key doesn't exist, $default is returned.
  * This method supports nested keys access: 'level1.level2.level3'
  *
  * @param string|StringObject $key     Array key. Eg: 'level1.level2.level3'
  * @param mixed               $default If key is not found, $default is returned.
  *
  * @return bool|mixed True is returned if the key exists, otherwise $default is returned.
  */
 public function keyExistsNested($key, $default = false)
 {
     $key = StdObjectWrapper::toString($key);
     if (strpos($key, '.') !== false) {
         $keys = explode('.', trim($key, '.'), 2);
         if (!isset($this->val()[$keys[0]])) {
             return $default;
         }
         $sourceArray = new ArrayObject($this->val()[$keys[0]]);
         return $sourceArray->keyExistsNested($keys[1], $default);
     }
     if (array_key_exists($key, $this->val())) {
         return true;
     }
     return $default;
 }