示例#1
0
 /**
  * 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);
 }
示例#2
0
 /**
  * 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;
 }