ReplaceClass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mutate() 0 7 2
A add() 0 5 1
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