1 | <?php |
||
11 | class MediaTokenTransformer implements DataTransformerInterface |
||
12 | { |
||
13 | /** |
||
14 | * @param mixed $content |
||
15 | * |
||
16 | * @return string |
||
17 | */ |
||
18 | 1 | public function transform($content) |
|
19 | { |
||
20 | 1 | if (!trim($content)) { |
|
21 | return ''; |
||
22 | } |
||
23 | |||
24 | 1 | $crawler = new Crawler(); |
|
25 | 1 | $crawler->addHtmlContent($content); |
|
26 | |||
27 | 1 | $crawler->filter('img,a')->each( |
|
28 | function (Crawler $node) { |
||
29 | 1 | $element = $node->getNode(0); |
|
30 | 1 | $attribute = $element->nodeName === 'img' ? 'src' : 'href'; |
|
31 | 1 | if ($element->hasAttribute('data-' . $attribute)) { |
|
|
|||
32 | 1 | $attributeValue = $element->getAttribute('data-' . $attribute); |
|
33 | 1 | $element->setAttribute($attribute, $attributeValue); |
|
34 | 1 | $element->removeAttribute('data-' . $attribute); |
|
35 | } |
||
36 | 1 | } |
|
37 | ); |
||
38 | |||
39 | try { |
||
40 | 1 | return $crawler->html(); |
|
41 | } catch (\InvalidArgumentException $exception) { |
||
42 | return $content; |
||
43 | } |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param mixed $content |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 1 | public function reverseTransform($content) |
|
93 | } |
||
94 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.