RequestEvent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 2 Features 3
Metric Value
wmc 2
c 4
b 2
f 3
cbo 1
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getRequest() 0 4 1
1
<?php
2
namespace Fwk\Core\Events;
3
4
use Fwk\Core\Application;
5
use Fwk\Core\Context;
6
use Fwk\Core\CoreEvent;
7
use Fwk\Core\AppEvents;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class RequestEvent extends CoreEvent
11
{
12 26
    public function __construct(Request $request, Application $app = null, 
13
        Context $context = null
14
    ) {
15 26
        parent::__construct(
16 26
            AppEvents::REQUEST, 
17 26
            array('request'  =>  $request), 
18 26
            $app, 
19
            $context
20 26
        );
21 26
    }
22
    
23
    /**
24
     * Gets the Request instance
25
     * 
26
     * @return Request
27
     */
28 26
    public function getRequest()
29
    {
30 26
        return $this->request;
0 ignored issues
show
Documentation introduced by
The property request does not exist on object<Fwk\Core\Events\RequestEvent>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
31
    }
32
}