Passed
Push — master ( fe64ef...2e5fa1 )
by Ivan
02:01
created

ReplaceClass::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\AjaxcomBundle\Mutation;
6
7
use Everlution\Ajaxcom\Handler;
8
9
/**
10
 * Class ReplaceClass.
11
 *
12
 * @author Ivan Barlog <[email protected]>
13
 */
14
class ReplaceClass implements MutatorInterface
15
{
16
    private $selectors = [];
17
18
    public function mutate(Handler $ajax): Handler
19
    {
20
        foreach ($this->selectors as $selector => $class) {
21
            $ajax->container($selector)->attr('class', $class);
22
        }
23
24
        return $ajax;
25
    }
26
27
    public function add(string $selector, string $class): self
28
    {
29
        $this->selectors[$selector] = $class;
30
31
        return $this;
32
    }
33
}
34