To string.

@param bool $recursive

@return string
516573
public function valueToString($recursive = true)
    {
        if ($this->countChildren() === 0) {
            return $this->getValue();
        }

        return implode(' ', array_map(function ($node) use ($recursive) {
            return $recursive ? $node->valueToString() : $node->getValue();
        }, $this->getChildren()));
    }
909199
public function writeComponents($recursive = false)
    {
        foreach ($this->components as $component) {
            $component->write(false, false, false, $recursive);
        }

        if ($join = $this->getJoin()) {
            $join->write(false, false, false, $recursive);
        }

        return $this;
    }
679114
public function process($recursive = false)
		{
			// reset
			$this->folders      = [];
			$this->controllers  = [];
			
			// variables
			$files = array_diff(scandir($this->path), ['.', '..']);

			// loop
			foreach ($files as $file)
			{
				$path = $this->path . $file;
				if(is_dir($path))
				{
					$this->folders[] = new Folder($path, $recursive);
				}
				else if(is_file($path) && preg_match('/Controller.php$/', $path))
				{
					$this->controllers[] = new Controller($path);
				}
			}
		}
627459
public function toString(bool $full = false)
    {
        if (count($this->message) == 0) {
            return null;
        }

        if ($full) {
            return implode(PHP_EOL, $this->message);
        } else {
            return $this->message[0];
        }
    }
241245
public function isAssoc(bool $recursive = false): bool
    {
        if ($this->isEmpty()) {
            return false;
        }

        foreach ($this->keys($recursive)->getGenerator() as $key) {
            if (!\is_string($key)) {
                return false;
            }
        }

        return true;
    }
1370590
public function listFolder(string $path, bool $recursive = false) : array
	{
		$path = $this->normalizePath($path);
			
		$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$path.'\')/Folders';
		
		$options = [
			'headers' => $this->requestHeaders,
		];
			
		$response = $this->send('GET', $requestUrl, $options);
			
		$folders = json_decode($response->getBody())->d ?? ['results' => []];
			
		// Making sure we convert the object to an array
		if (!is_array($folders)) {
			$folders = json_decode(json_encode($folders), true);
		}
			
		return $folders['results'];
	}
309342
protected function implode_recursive($glue = '', $pieces = [], bool $useKeys = false): string
    {
        if ($pieces instanceof self) {
            $pieces = $pieces->getArray();
        }

        if (\is_array($pieces)) {
            $pieces_count = \count($pieces, \COUNT_NORMAL);
            $pieces_count_not_zero = $pieces_count > 0;

            return \implode(
                $glue,
                \array_map(
                    [$this, 'implode_recursive'],
                    \array_fill(0, ($pieces_count_not_zero ? $pieces_count : 1), $glue),
                    ($useKeys === true && $pieces_count_not_zero ? $this->array_keys_recursive($pieces) : $pieces)
                )
            );
        }

        return (string) $pieces;
    }
49401
public function getList( $path = "", $recursive = FALSE )
	{
		$this->connection->checkConnection();
		$parsed	= array();
		if( !$path )
			$path	= $this->getPath();
		$list	= ftp_rawlist( $this->connection->getResource(), $path );
		if( is_array( $list ) )
		{
			foreach( $list as $current )
			{
				$data	= $this->parseListEntry( $current );
				if( count( $data ) )
				{
					$parsed[]	= $data;
					if( $recursive && $data['isdir'] && $data['name'] != "." && $data['name'] != ".." )
					{
						$nested	= $this->getList( $path."/".$data['name'], TRUE );
						foreach( $nested as $entry )
						{
							$entry['name']	= $data['name']."/".$entry['name'];
							$parsed[]	= $entry;
						}
					}
				}
			}
		}
		return $parsed;
	}
1188082
public function toArray($recursive = true)
    {
        $values = $this->values;

        if (!$recursive) {
            return $values;
        }

        foreach ($values as $key => $value) {
            if (gettype($value) === 'object') {
                if ($value instanceof Hash) {
                    $value = $value->toArray($recursive);
                }
            }

            $values[$key] = $value;
        }

        return $values;
    }
51225
public function toArray($recursively = false)
    {
        $rtn = [];

        foreach ($this->data as $k => $v) {

            if ($recursively && $v instanceof Arrayable) {
                $rtn[$k] = $v->toArray(true);
                continue;
            }

            $rtn[$k] = $v;
        }

        return $rtn;
    }
17999
static public function getFolders( $dir, $recursive = false )
    {
        $subDirs = [];
        if ( ( $dh = opendir( $dir ) ) ) {
            while ( ( $file = readdir( $dh ) ) !== false ) {
                if ( $file !== '.' && $file !== '..' && is_dir( $dir . '/' . $file ) ) {
                    $subDirs[] = $file;
                    if ( $recursive ) {
                        $subDirs = array_merge( $subDirs, self::getFolders( $dir . DS . $file, true ) );
                    }
                }
            }
            closedir( $dh );
        }
        return $subDirs;
    }
9280
private static function _toArray($data, $recursion = false)
    {
        $tmp  = array();
        $data = (array) $data;
        foreach ($data as $k => $v) {
            $v = (array) $v;
            if (isset($v[0]) && is_string($v[0])) {
                $tmp[$k] = $v[0];
            } else {
                $tmp[$k] = self::_toArray($v, true);
            }
        }
        return $tmp;
    }
121139
public function listContents(string $directory = '', bool $recursive = false): array
    {
        list($prefix, $directory) = $this->getPrefixAndPath($directory);

        $fs     = $this->getFileSystem($prefix);
        $list   = $fs->listContents($directory, $recursive);

        foreach ($list as &$file) {
            $file['filesystem'] = $prefix;
        }

        unset($prefix, $directory, $fs);

        return $list;
    }
1295238
public static function directoryToArray($directory, $recursive = FALSE, $extension = NULL) {
    $array_items = array();
    if ($handle = opendir($directory)) {
      while (FALSE !== ($file = readdir($handle))) {
        if ($file != "." && $file != ".." && (empty($extension) ||
            (!empty($extension) && substr($file, -strlen($extension)) === $extension))
        ) {

          if (is_dir($directory . "/" . $file)) {
            if ($recursive) {
              $array_items = array_merge($array_items, self::directoryToArray($directory . "/" . $file, $recursive));
            }
          }
          else {
            $file = $directory . "/" . $file;
            $array_items[] = preg_replace("/\/\//si", "/", $file);
          }
        }
      }
      closedir($handle);
    }
    return $array_items;
  }
665106
public function toArray($recursively = false) {
		$array = [];
		
		if ($recursively === true) {
			foreach($this->_map as $key) {
				$array[$key] = $this->getItem($key)->toArray();
			}
		} else {
			foreach($this->_map as $key) {
				$array[$key] = $this->getItem($key);
			}
		}

		return $array;
	}
189812
public function listPaths(string $path = '', bool $recursive = false)
    {
        $result = [];
        $contents = $this->listContents($path, $recursive);

        foreach ($contents as $object) {
            $result[] = $object['path'];
        }

        return $result;
    }
247967
public function getNumItems($recursive = false)
	{
		if ($recursive)
		{
			$count = $this->numitems;

			foreach ($this->getChildren() as $child)
			{
				$count = $count + $child->getNumItems(true);
			}

			return $count;
		}

		return $this->numitems;
	}