Completed
Push — master ( 524cff...dc4813 )
by
unknown
07:00
created

src/events/RegisterAttributesTransformer.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dsmrt
5
 * Date: 3/1/18
6
 * Time: 9:11 PM
7
 */
8
9
namespace flipbox\saml\sp\events;
10
11
12
use flipbox\saml\sp\transformers\AbstractResponse;
13
use yii\base\Event;
14
use yii\base\InvalidConfigException;
15
16
class RegisterAttributesTransformer extends Event
17
{
18
19
    protected $transformers = [];
20
21
    /**
22
     * @param string $entityId
23
     * @param string $class
24
     * @return $this
25
     * @throws InvalidConfigException
26
     */
27
    public function setTransformer(string $entityId, string $class)
28
    {
29
        if (! class_exists($class) || ! (new $class(new User) instanceof AbstractResponse)) {
0 ignored issues
show
The class flipbox\saml\sp\transformers\AbstractResponse does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
30
            throw new InvalidConfigException(
31
                sprintf(
32
                    "Transformer must be class of instanceof %s. %s was given and incorrect.",
33
                    AbstractResponse::class,
34
                    $class
35
                )
36
            );
37
        }
38
        $this->transformers[$entityId] = $class;
39
        return $this;
40
    }
41
42
    /**
43
     * @param $entityId
44
     * @return mixed|null
45
     */
46
    public function getTransformer($entityId)
47
    {
48
        return isset($this->transformers[$entityId]) ? $this->transformers[$entityId] : null;
49
    }
50
}