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/Calendar.php (1 issue)

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;
13
14
use CalendR\Event\Manager;
15
use CalendR\Period\Factory;
16
use CalendR\Period\FactoryInterface;
17
use CalendR\Period\PeriodInterface;
18
19
/**
20
 * Factory class for calendar handling.
21
 *
22
 * @author Yohan Giarelli <[email protected]>
23
 */
24
class Calendar
25
{
26
    /**
27
     * @var Manager
28
     */
29
    private $eventManager;
30
31
    /**
32
     * @var FactoryInterface
33
     */
34
    protected $factory;
35
36
    /**
37
     * @param Manager $eventManager
38
     */
39
    public function setEventManager(Manager $eventManager)
40
    {
41
        $this->eventManager = $eventManager;
42
    }
43
44
    /**
45
     * @return Manager
46
     */
47
    public function getEventManager()
48
    {
49
        if (null === $this->eventManager) {
50
            $this->eventManager = new Manager();
51
        }
52
53
        return $this->eventManager;
54
    }
55
56
    /**
57
     * @param $yearOrStart
58
     *
59
     * @return Period\Year
60
     */
61
    public function getYear($yearOrStart)
62
    {
63
        if (!$yearOrStart instanceof \DateTime) {
64
            $yearOrStart = new \DateTime(sprintf('%s-01-01', $yearOrStart));
65
        }
66
67
        return $this->getFactory()->createYear($yearOrStart);
68
    }
69
70
    /**
71
     * @param \DateTime|int $yearOrStart year if month is filled, month begin datetime otherwise
72
     * @param null|int      $month       number (1~12)
73
     *
74
     * @return PeriodInterface
75
     */
76
    public function getMonth($yearOrStart, $month = null)
77
    {
78
        if (!$yearOrStart instanceof \DateTime) {
79
            $yearOrStart = new \DateTime(sprintf('%s-%s-01', $yearOrStart, $month));
80
        }
81
82
        return $this->getFactory()->createMonth($yearOrStart);
83
    }
84
85
    /**
86
     * @param \DateTime|int $yearOrStart
87
     * @param null|int      $week
88
     *
89
     * @return PeriodInterface
90
     */
91
    public function getWeek($yearOrStart, $week = null)
92
    {
93
        $factory = $this->getFactory();
94
95
        if (!$yearOrStart instanceof \DateTime) {
96
            $yearOrStart = new \DateTime(sprintf('%s-W%s', $yearOrStart, str_pad($week, 2, 0, STR_PAD_LEFT)));
97
        }
98
99
        return $factory->createWeek($factory->findFirstDayOfWeek($yearOrStart));
100
    }
101
102
    /**
103
     * @param \DateTime|int $yearOrStart
104
     * @param null|int      $month
105
     * @param null|int      $day
106
     *
107
     * @return PeriodInterface
108
     */
109
    public function getDay($yearOrStart, $month = null, $day = null)
110
    {
111
        if (!$yearOrStart instanceof \DateTime) {
112
            $yearOrStart = new \DateTime(sprintf('%s-%s-%s', $yearOrStart, $month, $day));
113
        }
114
115
        return $this->getFactory()->createDay($yearOrStart);
116
    }
117
118
    /**
119
     * @param \DateTime|int $yearOrStart
120
     * @param null|int      $month
121
     * @param null|int      $day
122
     *
123
     * @return PeriodInterface
124
     */
125
    public function getHour($yearOrStart, $month = null, $day = null, $hour = null)
126
    {
127
        if (!$yearOrStart instanceof \DateTime) {
128
            $yearOrStart = new \DateTime(sprintf('%s-%s-%s %s:00', $yearOrStart, $month, $day, $hour));
129
        }
130
131
        return $this->getFactory()->createHour($yearOrStart);
132
    }
133
134
    /**
135
     * @param \DateTime|int $yearOrStart
136
     * @param null|int      $month
137
     * @param null|int      $day
138
     *
139
     * @return PeriodInterface
140
     */
141
    public function getMinute($yearOrStart, $month = null, $day = null, $hour = null, $minute = null)
142
    {
143
        if (!$yearOrStart instanceof \DateTime) {
144
            $yearOrStart = new \DateTime(sprintf('%s-%s-%s %s:%s', $yearOrStart, $month, $day, $hour, $minute));
145
        }
146
147
        return $this->getFactory()->createMinute($yearOrStart);
148
    }
149
150
    /**
151
     * @param \DateTime|int $yearOrStart
152
     * @param null|int      $month
153
     * @param null|int      $day
154
     *
155
     * @return PeriodInterface
156
     */
157
    public function getSecond($yearOrStart, $month = null, $day = null, $hour = null, $minute = null, $second = null)
158
    {
159
        if (!$yearOrStart instanceof \DateTime) {
160
            $yearOrStart = new \DateTime(
161
                sprintf('%s-%s-%s %s:%s:%s', $yearOrStart, $month, $day, $hour, $minute, $second)
162
            );
163
        }
164
165
        return $this->getFactory()->createSecond($yearOrStart);
166
    }
167
168
    /**
169
     * @param Period\PeriodInterface $period
170
     * @param array                  $options
171
     *
172
     * @return array<Event\EventInterface>
0 ignored issues
show
Should the return type not be array|Event\EventInterface?

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...
173
     */
174
    public function getEvents(PeriodInterface $period, array $options = array())
175
    {
176
        return $this->getEventManager()->find($period, $options);
177
    }
178
179
    /**
180
     * @param FactoryInterface $factory
181
     */
182
    public function setFactory(FactoryInterface $factory)
183
    {
184
        $this->factory = $factory;
185
    }
186
187
    /**
188
     * @return FactoryInterface
189
     */
190
    public function getFactory()
191
    {
192
        if (null === $this->factory) {
193
            $this->factory = new Factory();
194
        }
195
196
        return $this->factory;
197
    }
198
199
    /**
200
     * @param int $firstWeekday
201
     */
202
    public function setFirstWeekday($firstWeekday)
203
    {
204
        $this->getFactory()->setFirstWeekday($firstWeekday);
205
    }
206
207
    /**
208
     * @return int
209
     */
210
    public function getFirstWeekday()
211
    {
212
        return $this->factory->getFirstWeekday();
213
    }
214
}
215