Completed
Push — master ( daab91...b549ed )
by Derek Stephen
02:54 queued 11s
created

CaptchaRender   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderBlock() 0 16 2
1
<?php declare(strict_types=1);
2
3
namespace Del\Form\Renderer\Field;
4
5
use Del\Form\Field\Captcha;
6
use Del\Form\Field\FieldInterface;
7
use DOMDocument;
8
use DOMElement;
9
10
class CaptchaRender extends AbstractFieldRender implements FieldRendererInterface
11
{
12
    /**
13
     * @param FieldInterface $field
14
     * @param DOMElement $element
15
     * @return DOMElement
16
     */
17
    public function renderBlock(FieldInterface $field, DOMElement $element): DOMElement
18
    {
19
        if (!$field instanceof Captcha) {
20
            throw new InvalidArgumentException('Must be a Del\Form\Field\Captcha');
21
        }
22
23
        $dom = $this->getDom();
24
        $captcha = $dom->createDocumentFragment();
25
        $captcha->appendXML($field->getCaptchAdapter()->render());
26
27
        $div = $this->getDom()->createElement('div');
28
        $div->appendChild($captcha);
29
        $div->appendChild($element);
30
31
        return $div;
32
    }
33
}
34