original_string: public function mkdir($path, $mode = 0777, $recursive = false)
      {
          if (null !== $this->at($path)) {
              trigger_error("mkdir(): File exists");
              return false;
          }
  
          $parts = explode('/', $this->realpath($path));
          $filesCount = 0;
          $missing = [];
          $item = array_shift($parts);
          foreach ($parts as $part) {
              $item .= "/{$part}";
              $node = $this->at($item);
              if ($node === null) {
                  $missing[] = $item;
              } else if ($node->type == 'file') {
                  $filesCount ++;
              }
          }
  
          if ($filesCount > 0) {
              trigger_error("mkdir(): Not a directory");
              return false;
          }
  
          if (count($missing) > 1 && !$recursive) {
              trigger_error("mkdir(): No such file or directory");
              return false;
          }
  
          foreach ($missing as $path) {
              $this->at($path, (object) [
                  'type' => 'dir',
                  'perms' => $mode
              ]);
          }
  
          return true;
     }
code: public function mkdir($path, $mode = 0777, $recursive = false)
      {
          if (null !== $this->at($path)) {
              trigger_error("mkdir(): File exists");
              return false;
          }
  
          $parts = explode('/', $this->realpath($path));
          $filesCount = 0;
          $missing = [];
          $item = array_shift($parts);
          foreach ($parts as $part) {
              $item .= "/{$part}";
              $node = $this->at($item);
              if ($node === null) {
                  $missing[] = $item;
              } else if ($node->type == 'file') {
                  $filesCount ++;
              }
          }
  
          if ($filesCount > 0) {
              trigger_error("mkdir(): Not a directory");
              return false;
          }
  
          if (count($missing) > 1 && !$recursive) {
              trigger_error("mkdir(): No such file or directory");
              return false;
          }
  
          foreach ($missing as $path) {
              $this->at($path, (object) [
                  'type' => 'dir',
                  'perms' => $mode
              ]);
          }
  
          return true;
     }
code_tokens: public function mkdir ( $ path , $ mode = 0777 , $ recursive = false ) { if ( null !== $ this -> at ( $ path ) ) { trigger_error ( "mkdir(): File exists" ) ; return false ; } $ parts = explode ( '/' , $ this -> realpath ( $ path ) ) ; $ filesCount = 0 ; $ missing = [ ] ; $ item = array_shift ( $ parts ) ; foreach ( $ parts as $ part ) { $ item .= "/{$part}" ; $ node = $ this -> at ( $ item ) ; if ( $ node === null ) { $ missing [ ] = $ item ; } else if ( $ node -> type == 'file' ) { $ filesCount ++ ; } } if ( $ filesCount > 0 ) { trigger_error ( "mkdir(): Not a directory" ) ; return false ; } if ( count ( $ missing ) > 1 && ! $ recursive ) { trigger_error ( "mkdir(): No such file or directory" ) ; return false ; } foreach ( $ missing as $ path ) { $ this -> at ( $ path , ( object ) [ 'type' => 'dir' , 'perms' => $ mode ] ) ; } return true ; }
docstring: Equivalent to PHP `mkdir` function.
  
  @param  string  $path
  @return boolean
docstring_tokens: Equivalent to PHP mkdir function .