Hoa central
Vfs.php
Go to the documentation of this file.
1 <?php
2 
38 
39 use atoum;
40 use Hoa\Core;
41 
50 class Vfs extends Core\Protocol
51 {
57  protected $_name = 'Vfs';
58 
64  protected $_streams = [];
65 
66 
67 
75  public function reach($queue = null)
76  {
77  if (null === $queue) {
78  return null;
79  }
80 
81  $components = parse_url($queue);
82  $path = &$components['path'];
83 
84  if (isset($components['query'])) {
85  parse_str($components['query'], $queries);
86  } else {
87  $queries = ['type' => 'file'];
88  }
89 
90  if (isset($queries['type']) &&
91  'directory' === $queries['type']) {
92  $file = atoum\mock\streams\fs\directory::get($path);
93  $file->dir_opendir = true;
94  } else {
95  $file = atoum\mock\streams\fs\file::get($path);
96  }
97 
98  $parentDirectory = dirname($path);
99 
100  if (isset($this->_streams[$parentDirectory])) {
101  $this->_streams[$parentDirectory]->dir_readdir[] = $file;
102  }
103 
104  foreach ($queries as $query => $value) {
105  switch ($query) {
106  case 'atime':
107  case 'ctime':
108  case 'mtime':
109  $file->getStat()[$query] = intval($value);
110 
111  break;
112 
113  case 'permissions':
114  $value = sprintf('%04d', $value);
115  $file->setPermissions($value);
116 
117  break;
118  }
119  }
120 
121  $this->_streams[$path] = $file;
122 
123  return (string) $file;
124  }
125 }
reach($queue=null)
Definition: Vfs.php:75