Embera\Formatter::transform PHP Метод

transform() публичный Метод

This method transforms an array or a string with urls into another string using a specified template.
public transform ( string | array $body = null ) : string
$body string | array An array or string with Urls
Результат string
    public function transform($body = null)
    {
        $providers = array();
        if ($urls = $this->embera->getUrlInfo($body)) {
            foreach ($urls as $url => $data) {
                if (!$this->allowOffline && (int) $data['embera_using_fake'] === 1) {
                    $this->errors[] = 'Using fake oembed response on ' . $url;
                    continue;
                }
                $providers[$url] = $this->replace($data, $this->template);
            }
        }
        if (is_array($body)) {
            $return = implode('', $providers);
        } else {
            $return = str_replace(array_keys($providers), array_values($providers), $body);
        }
        // Remove unchanged placeholders
        return preg_replace('~{([\\w\\d\\-_]+)}~i', '', $return);
    }