turns given list of elements into a line suitable for csv

@param   string[]  $elements
@param   resource  $memory
@return  string
194561
private function toCsvLine(array $elements, $memory): string
    {
        ftruncate($memory, 0);
        rewind($memory);
        fputcsv($memory, $elements, $this->delimiter, $this->enclosure);
        rewind($memory);
        return stream_get_contents($memory);
    }
968139
public function itemsToFormat(array $items): string
    {
        return $this->strToCSV(array_map(function (Item $item) {
            return [
                $item->getId(),
                $item->getType(),
                json_encode($item->getMetadata()),
                json_encode($item->getIndexedMetadata()),
                json_encode($item->getSearchableMetadata()),
                json_encode($item->getExactMatchingMetadata()),
                json_encode($item->getSuggest()),
                json_encode(
                    ($item->getCoordinate() instanceof Coordinate)
                        ? $item->getCoordinate()->toArray()
                        : null
                ),
            ];
        }, $items));
    }
225445
public function page($fields = null, $page = 1, $entries = 5)
    {
        $chunks = array_chunk($this->storage, $entries);
        $offset = $page - 1;

        if (isset($chunks[ $offset ])) {
            $result = new ArrayIterator($chunks[ $offset ]);

            if (empty($fields)) {
                return $this->result = $result;
            } else {
                foreach ($result as $row) {
                    $item = new SplArrayObject();
                    foreach ($fields as $field) {
                        if ($row->offsetExists($field)) {
                            $item[ $field ] = $row->offsetGet($field);
                        }
                    }

                    $this->result[] = $item;
                }

                return $this->result;
            }
        }

        return false;
    }
394276
public function inlineCssOnElement(\DOMElement $element, array $properties)
    {
        if (empty($properties)) {
            return $element;
        }

        $cssProperties = array();
        $inlineProperties = array();

        foreach ($this->getInlineStyles($element) as $property) {
            $inlineProperties[$property->getName()] = $property;
        }

        foreach ($properties as $property) {
            if (!isset($inlineProperties[$property->getName()])) {
                $cssProperties[$property->getName()] = $property;
            }
        }

        $rules = array();
        foreach (array_merge($cssProperties, $inlineProperties) as $property) {
            $rules[] = $property->toString();
        }
        $element->setAttribute('style', implode(' ', $rules));

        return $element;
    }
1062036
protected function serializeElement($element)
	{
		return (is_array($element)) ? $this->serializeStrings($element) : $this->serializeLiteral($element);
	}
436668
function docBlock($lines) {
    if (!is_array($lines)) {
      $lines = array($lines);
    }

    $lines = array_merge(
      array("/**"),
      array_map(function ($line) {
        if (empty($line)) {
          return ' *';
        }
        return " * $line";
      }, $lines),
      array(" */")
    );

    return $lines;
  }
72238
public function element(String $element, String $str = NULL, Array $attributes = []) : String
    {
        return $this->_multiElement($element, $str, $attributes);
    }
1016244
public void write(Collection<? extends E> elements) throws IOException {
		final Progression progressBar = getTaskProgression();
		Progression subTask = null;

		if (progressBar != null) {
			progressBar.setProperties(0, 0, (elements.size() + 1) * 100, false);
		}

		if (this.fileBounds == null) {
			this.fileBounds = getFileBounds();
		}

		if (this.fileBounds != null) {
			writeHeader(this.fileBounds, this.elementType, elements);

			if (progressBar != null) {
				progressBar.setValue(100);
				subTask = progressBar.subTask(elements.size() * 100);
				subTask.setProperties(0, 0, elements.size(), false);
			}

			for (final E element : elements) {

				writeElement(this.recordIndex, element, this.elementType);

				if (subTask != null) {
					subTask.setValue(this.recordIndex + 1);
				}

				++this.recordIndex;

			}
		} else {
			throw new BoundsNotFoundException();
		}

		if (progressBar != null) {
			progressBar.end();
		}
	}
495232
public function typify(array $node_elements)
	{
		$node_element = $node_elements[0];
		$tag_name = $node_element->getTagName();

		if ( $tag_name == 'input' ) {
			$input_type = $node_element->getAttribute('type');

			if ( $input_type == self::CHECKBOX_INPUT ) {
				return Checkbox::fromNodeElement($node_element, $this->getPageFactory());
			}
			elseif ( $input_type == self::RADIO_INPUT ) {
				return RadioGroup::fromNodeElements($node_elements, null, $this->getPageFactory());
			}
			elseif ( $input_type == self::FILE_INPUT ) {
				return FileInput::fromNodeElement($node_element, $this->getPageFactory());
			}
			else {
				/*if ( is_null($input_type)
					|| ($input_type == self::TEXT_INPUT)
					|| ($input_type == self::PASSWORD_INPUT)
				) {*/
				return TextInput::fromNodeElement($node_element, $this->getPageFactory());
			}
		}
		elseif ( $tag_name == 'select' ) {
			return Select::fromNodeElement($node_element, $this->getPageFactory());
		}
		elseif ( $tag_name == 'textarea' ) {
			return TextInput::fromNodeElement($node_element, $this->getPageFactory());
		}

		$web_element = WebElement::fromNodeElement($node_element, $this->getPageFactory());
		throw new FormException(
			'Unable create typified element for ' . (string)$web_element,
			FormException::TYPE_UNKNOWN_FIELD
		);
	}
301172
protected function formatFormElement(array $element)
    {
        $sm = $this->getServiceLocator();
        $result = array();
        if (array_key_exists('lazy-set', $element)) {
            $result = $sm->get($this->moduleService)->lazySet($element['lazy-set']);
        }
        $result['name'] = $element['name'];
        $result['type'] = $element['type'];
        if (array_key_exists('label', $element)) {
            $result['options']['label'] = $element['label'];
        }
        return $result;
    }
1354249
public static function processLegend(array $element) {
    if ($element['#legend']) {
      foreach (RenderElement::children($element) as $key) {
        if (is_callable($element['#legend'])) {
          $element[$key]['#description'] = $element['#legend']($element[$key]);
        }
        elseif (isset($element['#legend'][$key])) {
          $element[$key]['#description'] = $element['#legend'][$key];
        }
      }
    }
    return $element;
  }
174536
public static String join(final String delimiter, final Collection<?> elements)
	{
		if (elements == null || elements.isEmpty())
		{
			return "";
		}
		return join(delimiter, elements.toArray(new Object[elements.size()]));
	}
16856
protected function element(array $Element)
    {
        $markup = '';

        if (str_is('h[1-6]', $Element['name'])) {
            $link = str_replace(' ', '-', strtolower($Element['text']));
            $markup = '<a  class="header-link" href="#'.$link.'" id="'.$link.'"><i class="glyphicon glyphicon-link"></i></a>';
        }

        $markup .= parent::element($Element);

        return $markup;
    }
148415
protected function getBlockList(\DOMElement $element) {
    $lines = array();
    $prefix = $element->nodeName == 'ol' ? ' 1. ' : ' - ';
    // Markdown does not support definition lists, convert to ul.
    if ($element->nodeName == 'dl') {
      $newline = TRUE;
      /** @var \DOMElement $child */
      foreach ($element->childNodes as $child) {
        switch ($child->nodeName) {

          case 'dt':
            if ($newline) {
              $lines[] = $prefix . $this->getBlock($child);
            }
            else {
              $lines[count($lines) - 1] .= '<br/>' . $this->getBlock($child);
            }
            $newline = FALSE;
            break;

          case 'dd':
            $lines[count($lines) - 1] .= '<br/>' . $this->getBlock($child);
            $newline = TRUE;
            break;

        }
      }
    }
    else {
      /** @var \DOMElement $child */
      foreach ($element->childNodes as $child) {
        switch ($child->nodeName) {

          case 'li':
            $lines[] = $prefix . $this->getBlock($child);
            break;

        }
      }
    }
    return implode("\n", $lines);
  }
1199655
protected function writeElement($element): void
    {
        if (!is_array($element)) {
            $type = (is_object($element) ? get_class($element) . ' ' : '') . gettype($element);
            trigger_error("Unable to write to element to CSV stream; expect array, $type given", E_USER_WARNING);

            fwrite($this->stream, "\n");
            return;
        }

        fputcsv($this->stream, $element, $this->delimiter, $this->enclosure, $this->escapeChar);
    }
518453
static function build_line($array)
    {
        if (self::$data_sep)
        {
            $line = '';
            foreach ($array as $k => $v)
            {
                $line .= $k . self::$data_sep . $v . self::$col_sep;
            }
            return rtrim($line, self::$col_sep);
        }
        else
        {
            return implode(self::$col_sep, $array);
        }
    }
1335999
private function prepareElements(array $elementsData, $acceptScalar = true)
    {
        $elements = [];
        foreach ($elementsData as $key => $data) {
            if (true === $acceptScalar && is_scalar($data)) {
                $elements[$key] = $data;
                continue;
            }

            if (!is_array($data)) {
                continue;
            }

            if (isset($data['type']) && isset($data['uid'])) {
                if (null !== $element = $this->findOneByTypeAndUid($data['type'], $data['uid'])) {
                    $elements[$key] = $element;
                }

                continue;
            }

            $elements[$key] = [];
            foreach ($data as $row) {
                if (
                    isset($row['type'])
                    && isset($row['uid'])
                    && null !== $element = $this->findOneByTypeAndUid($row['type'], $row['uid'])
                ) {
                    $elements[$key][] = $element;
                }
            }
        }

        return $elements;
    }