| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function generate($id) |
||
| 16 | { |
||
| 17 | if (!$this->cache->isAutopromoBannerConfigured()) { |
||
| 18 | return ''; |
||
| 19 | } |
||
| 20 | |||
| 21 | $url = $this->cache->getAutopromoBannerUrl(); |
||
| 22 | $script = $this->cache->getAutopromoBannerScript(); |
||
| 23 | |||
| 24 | $script = <<<EOS |
||
| 25 | (function (a,d){var s,t,cs,ds,dd;s=d.createElement('script');cs=d.currentScript; |
||
| 26 | ds=d.createElement('span');ds.id=Math.random().toString(36).substring(7); |
||
| 27 | dd=cs.parentNode.insertBefore(ds,cs); |
||
| 28 | s.src=a;s.async=1;s.setAttribute('data-dd',ds.id);s.setAttribute('data-id',$id); |
||
| 29 | t=d.getElementsByTagName('script')[0];t.parentNode.insertBefore(s,t);}) |
||
| 30 | ("https://$url/$script.js", document); |
||
| 31 | EOS; |
||
| 32 | |||
| 33 | return $script; |
||
| 34 | } |
||
| 35 | } |
||
| 36 |