ProviderTrait::accept()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace DoS\SMSBundle\SMS\Provider;
4
5
use DoS\SMSBundle\Provider\RecordProvider;
6
use DoS\SMSBundle\SMS\ProviderCallbackInterface;
7
use DoS\SMSBundle\SMS\ProviderInterface;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
use Symfony\Component\PropertyAccess\PropertyAccess;
10
11
trait ProviderTrait
12
{
13
    /**
14
     * @var ProviderCallbackInterface
15
     */
16
    protected $callback;
17
18
    public function setCallback(ProviderCallbackInterface $callback = null)
19
    {
20
        $this->callback = $callback;
21
    }
22
23
    public function processCallback(array $data)
24
    {
25
        if ($this->callback) {
26
            $this->callback->process($data);
27
        }
28
    }
29
30
    public function getCallbackResults()
31
    {
32
        if ($this->callback) {
33
            return $this->callback->getResults();
34
        }
35
36
        return array();
37
    }
38
39
    public function accept(RecordProvider $visitor)
40
    {
41
        /* @var ProviderInterface $this */
42
        $visitor->visit($this);
43
    }
44
45
    public function applyOptions(array $options = array())
46
    {
47
        $accessor = PropertyAccess::createPropertyAccessor();
48
        $this->validateOptions($options);
49
50
        foreach ($options as $key => $value) {
51
            $accessor->setValue($this, $key, $value);
52
        }
53
    }
54
55
    public function validateOptions(array $options)
56
    {
57
        $resolver = new OptionsResolver();
58
        $this->configureOptions($resolver);
59
        $resolver->resolve($options);
60
    }
61
62
    public function configureOptions(OptionsResolver $resolver)
0 ignored issues
show
Unused Code introduced by
The parameter $resolver is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
    {
64
    }
65
}
66