@param array  $storage
@param string $path
@param bool   $xss

@return mixed

@throws ExceptionEmpty
505064
protected function arrRequired(array $storage, $path, $xss)
    {
        $data = $this->helper->arr()->getRequired($storage, $path);

        if ($xss)
        {
            $data = $this->xss($data);
        }

        return $data;
    }
1125543
public function rm( $path )
	{
		try {
			$this->fs->delete( $path );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
82945
protected function checkStorageId($path, Storage $storage, StorageRepository $rep)
    {
        if (!file_exists($path.StorageListener::ID_FILE)) {
            // path is free. reserve for me
            file_put_contents($path.StorageListener::ID_FILE, $storage->getId());
        } elseif (file_get_contents($path.StorageListener::ID_FILE) == $storage->getId()) {
            // it is my path. do nothing
        } elseif (!($duplicate = $rep->find(file_get_contents($path.StorageListener::ID_FILE)))) {
            // this path is reserved storage that was removed and now this path is free
            file_put_contents($path.StorageListener::ID_FILE, $storage->getId());
        } else {
            return $duplicate;
        }

        return true;
    }
1321037
public function size( $path )
	{
		try {
			return $this->fs->size( $path );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
124439
protected function convert(DOMElement $element, $storage): void
    {
        if (\is_object($storage)) {
            $element->appendChild($element->ownerDocument->importNode($storage));
            return;
        }

        if (!\is_array($storage)) {
            $element->nodeValue = \htmlspecialchars($storage);
            return;
        }

        if (empty($storage)) {
            throw new Exceptions\Blank('Array is empty');
        }

        $isInt      = Arr::map(Arr::getKeys($storage), '\is_int');
        $sequential = !Arr::in($isInt, false);

        foreach ($storage as $key => $data) {
            if ($sequential) {
                $this->sequential($element, $data);
                continue;
            }

            $this->addNodeWithKey($key, $element, $data);
        }
    }
1217839
public function chdir($path)
	{
		// If native FTP support is enabled lets use it...
		if (FTP_NATIVE)
		{
			if (@ftp_chdir($this->conn, $path) === false)
			{
				throw new FilesystemException(__METHOD__ . 'Bad response.');
			}

			return true;
		}

		// Send change directory command and verify success
		if (!$this->_putCmd('CWD ' . $path, 250))
		{
			throw new FilesystemException(
				sprintf('%1$s: Bad response.  Server response: %2$s [Expected: 250].  Sent path: %3$s', __METHOD__, $this->response, $path)
			);
		}

		return true;
	}
293678
function unserialize($vars) {
        if(\CharlotteDunois\Yasmin\Models\ClientBase::$serializeClient === null) {
            throw new \Exception('Unable to unserialize a class without ClientBase::$serializeClient being set');
        }
        
        $vars = \unserialize($vars);
        
        foreach($vars as $name => $val) {
            $this->$name = $val;
        }
        
        $this->client = \CharlotteDunois\Yasmin\Models\ClientBase::$serializeClient;
        $this->commands = new \CharlotteDunois\Collect\Collection();
    }
694772
public function parse($path)
    {
        $data = json_decode(file_get_contents($path), true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            $error_message  = 'Syntax error';
            if (function_exists('json_last_error_msg')) {
                $error_message = json_last_error_msg();
            }
            
            throw new Exception($error_message);
        }
        return $data;
    }
113862
public function load()
    {
        if (empty($this->storage)) {
            throw new Exception('Empty config storage');
        }
        $storage = $this->getStorage();
        $storage->load();
        return $this->fromArray($storage->get());
    }
1174784
public function getFolder($container, $path, $include_files = true, $include_folders = true, $full_tree = false)
    {
        $delimiter = ($full_tree) ? '' : '/';
        $resources = [];
        if ($this->containerExists($container)) {
            if (!empty($path)) {
                if (!$this->blobExists($container, $path)) {
                    // blob may not exist for "fake" folders, i.e. S3 prefixes
                    throw new NotFoundException("Folder '$path' does not exist in storage.");
                }
            }
            $results = $this->listBlobs($container, $path, $delimiter);
            foreach ($results as $data) {
                $fullPathName = array_get($data, 'name');
                $data['path'] = $fullPathName;
                $data['name'] = rtrim(substr($fullPathName, strlen($path)), '/');
                if ('/' == substr($fullPathName, -1)) {
                    // folders
                    if ($include_folders) {
                        $data['type'] = 'folder';
                        $resources[] = $data;
                    }
                } else {
                    // files
                    if ($include_files) {
                        $data['type'] = 'file';
                        $resources[] = $data;
                    }
                }
            }
        } else {
            if (!empty($path)) {
                throw new NotFoundException("Folder '$path' does not exist in storage.");
            }
            // container root doesn't really exist until first write creates it
        }

        return $resources;
    }
963086
static function from ($path, $flags = 4096)
  {
    try {
      return new static (new FilesystemIterator($path, $flags));
    }
    catch (\Exception $e) {
      // Convert UnexpectedValueException to another type to prevent problems with some error handlers.
      throw new \InvalidArgumentException($e->getMessage ());
    }
  }
495401
public static function setPGTStorage($storage)
    {
        phpCAS :: traceBegin();
        phpCAS::_validateProxyExists();

        try {
            self::$_PHPCAS_CLIENT->setPGTStorage($storage);
        } catch (Exception $e) {
            phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
        }
        phpCAS :: traceEnd();
    }
534181
public static function decodeFromFile($path)
    {
        if (!is_file($path)) {
            throw new \Exception("File does not exist: {$path}");
        }

        $string = file_get_contents($path);

        if ($string === false) {
            throw new \Exception("Failed to read the file: {$path}");
        }

        if (!$string) {
            return [];
        }

        $array = json_decode($string, true);

        static::checkLastError();

        return $array;
    }
582739
public function fetchEtag($filename, $path) {
        $absPath = $this->_getAbsPath($filename, $path);

        $md5output = exec("cat {$absPath} | md5sum");
        if ($md5output) {
            $md5output = str_replace(array(' ', '-'), '', $md5output);
            return $md5output;
        }

        throw new Exception("Could not fetch md5 sum of {$path}.");
    }
1147256
private function doRequest($path, $headers = [])
    {
        if (!$this->isAvailable()) {
            throw new NotAvailableException('Service not available.');
        }

        if ($this->loadBalance !== null) {
            $uri = $this->loadBalance->getUri($this->serviceName);
            $this->zendClient->setUri($uri);
        }
        if ($this->appendPath && strlen($path) > 0 && $this->zendClient->getUri()->getPath() != '/') {
            $path = $this->zendClient->getUri()->getPath() . $path;
        }
        $this->zendClient->getUri()->setPath($path);

        $this->zendClient->getRequest()->getHeaders()->addHeaders($headers);

        if (!$this->zendClient->getRequest()->getHeaders()->has('X-Request-Id')) {
            $this->addRequestId();
        }

        $this->addRequestName($this->serviceName);

        $this->getEventManager()->trigger('request.pre', $this);

        $this->responseTime = 0;

        try {
            $requestTime = microtime(true);

            $zendHttpResponse = $this->zendClient->send();

            $this->responseTime = (float) sprintf('%.2f', (microtime(true) - $requestTime) * 1000);

            $this->addRequestTime($this->responseTime);

            $response = new Response($this->zendClient, $zendHttpResponse, $this->depth);
            $this->reportSuccess();
        } catch (RuntimeException $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), $ex->getCode(), $ex);
        } catch (\Exception $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), 500, $ex);
        }

        $this->getEventManager()->trigger('request.post', $this);

        $content = $response->getContent();

        return $content;
    }
1369037
public function reads( $path )
	{
		try {
			$content = $this->fs->get( $path );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}

		if( ( $stream = tmpfile() ) === false ) {
			throw new Exception( 'Couldn\'t create temporary file' );
		}

		if( fwrite( $stream, $content ) === false ) {
			throw new Exception( 'Couldn\'t write to temporary file' );
		}

		if( rewind( $stream ) === false ) {
			throw new Exception( 'Couldn\'t rewind temporary file' );
		}

		return $stream;
	}
296912
public function delete($path)
    {
        if (!$this->isFile($path)) {
            $path = $this->pathRoot.$path;
            throw new ExceptionStorage("File {$path} Not found or Not Is File", static::E_NOT_IS_FILE);
        }

        $metadata = $this->dropbox->delete($this->pathRoot.$path);
        return !is_null($metadata);
    }