Issues (11)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Event/Manager.php (2 issues)

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
/*
4
 * This file is part of CalendR, a Fréquence web project.
5
 *
6
 * (c) 2012 Fréquence web
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CalendR\Event;
13
14
use CalendR\Event\Exception\NoProviderFound;
15
use CalendR\Period\PeriodInterface;
16
use CalendR\Event\Provider\ProviderInterface;
17
18
/**
19
 * Manage events and providers.
20
 *
21
 * @author Yohan Giarelli <[email protected]>
22
 */
23
class Manager
24
{
25
    /**
26
     * @var ProviderInterface[]
27
     */
28
    protected $providers = array();
29
30
    /**
31
     * The callable used to instantiate the event collection.
32
     *
33
     * @var callable
34
     */
35
    protected $collectionInstantiator;
36
37
    /**
38
     * @param array $providers
39
     * @param null  $instantiator
40
     */
41
    public function __construct(array $providers = array(), $instantiator = null)
42
    {
43
        $this->collectionInstantiator = $instantiator;
44
        if (null === $instantiator) {
45
            $this->collectionInstantiator = function () {
46
                return new Collection\Basic();
47
            };
48
        }
49
50
        foreach ($providers as $name => $provider) {
51
            $this->addProvider($name, $provider);
52
        }
53
    }
54
55
    /**
56
     * find events that matches the given period (during or over).
57
     *
58
     * @param \CalendR\Period\PeriodInterface $period
59
     * @param array                           $options
60
     *
61
     * @return array|EventInterface
62
     *
63
     * @throws NoProviderFound
64
     */
65
    public function find(PeriodInterface $period, array $options = array())
0 ignored issues
show
This operation has 200 execution paths which exceeds the configured maximum of 200.

A high number of execution paths generally suggests many nested conditional statements and make the code less readible. This can usually be fixed by splitting the method into several smaller methods.

You can also find more information in the “Code” section of your repository.

Loading history...
66
    {
67
        if (0 === count($this->providers)) {
68
            throw new NoProviderFound();
69
        }
70
71
        // Check if there's a provider option provided, used to filter the used providers
72
        $providers = isset($options['providers']) ? $options['providers'] : array();
73
        if (!is_array($providers)) {
74
            $providers = array($providers);
75
        }
76
77
        // Instantiate an event collection
78
        $collection = call_user_func($this->collectionInstantiator);
79
        foreach ($this->providers as $name => $provider) {
80
            if (count($providers) > 0 && !in_array($name, $providers)) {
81
                continue;
82
            }
83
84
            // Add matching events to the collection
85
            foreach ($provider->getEvents($period->getBegin(), $period->getEnd(), $options) as $event) {
86
                if ($period->containsEvent($event)) {
87
                    $collection->add($event);
88
                }
89
            }
90
        }
91
92
        return $collection;
93
    }
94
95
    /**
96
     * Adds a provider to the provider stack.
97
     *
98
     * @param $name
99
     * @param ProviderInterface $provider
100
     */
101
    public function addProvider($name, ProviderInterface $provider)
102
    {
103
        $this->providers[$name] = $provider;
104
    }
105
106
    /**
107
     * Sets the callable used to instantiate the event collection.
108
     *
109
     * @param callable $collectionInstantiator
110
     */
111
    public function setCollectionInstantiator($collectionInstantiator)
112
    {
113
        $this->collectionInstantiator = $collectionInstantiator;
114
    }
115
116
    /**
117
     * @return \CalendR\Event\Provider\ProviderInterface
0 ignored issues
show
Should the return type not be ProviderInterface[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
118
     */
119
    public function getProviders()
120
    {
121
        return $this->providers;
122
    }
123
}
124