/** * Convert collection to given format. * * @param string $format * * @return static */ public function convert($format) { $converted = []; foreach ($this->words as $item) { if ($item instanceof Convertable) { $converted[] = $item->convert($format); continue; } $converted[] = Converter::convert($item, $format); } return new static($this->text, $converted, $this->pluginData); }
/** * Convert word properties to given format. * * @param string $format * * @return static */ public function convert($format) { $publicProperties = $this->getPublicProperties(); foreach ($publicProperties as $object) { $value = $object->name; $this->{$value} = Converter::convert($this->{$value}, $format); } return $this; }