Issues (1)

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/Weekday.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
namespace ChinLeung\LaravelWeekday;
4
5
use ChinLeung\Weekday\Weekday as PhpWeekday;
6
use Illuminate\Support\Collection;
7
8
class Weekday
9
{
10
    /**
11
     * The weekday instance.
12
     *
13
     * @var \ChinLeung\Weekday\Weekday
14
     */
15
    protected $instance;
16
17
    /**
18
     * Constructor of the class.
19
     *
20
     * @param  \ChinLeung\Weekday\Weekday  $instance
21
     */
22
    public function __construct(PhpWeekday $instance = null)
23
    {
24
        $this->instance = $instance;
25
    }
26
27
    /**
28
     * Forward the call to the Weekday instance.
29
     *
30
     * @param  string  $method
31
     * @param  array  $arguments
32
     * @return mixed
33
     */
34
    public function __call($method, $arguments)
35
    {
36
        return $this->getInstance()->$method(...$arguments);
37
    }
38
39
    /**
40
     * Retrieve the Weekday instance.
41
     *
42
     * @return  \ChinLeung\Weekday\Weekday
43
     */
44
    public function getInstance(): PhpWeekday
45
    {
46
        return $this->instance ?? new PhpWeekday;
0 ignored issues
show
The call to Weekday::__construct() misses some required arguments starting with $value.
Loading history...
47
    }
48
49
    /**
50
     * Retrieve the locale.
51
     *
52
     * @param  string|null  $locale
53
     * @return string
54
     */
55
    private function locale(?string $locale): string
56
    {
57
        return $locale ?: app()->getLocale();
58
    }
59
60
    /**
61
     * Retrieve the name of a weekday.
62
     *
63
     * @param  int  $value
64
     * @param  string  $locale
65
     * @return string
66
     */
67
    public function name(int $value, string $locale = null): string
68
    {
69
        return static::parse($value, $locale)
70
            ->getInstance()
71
            ->getName();
72
    }
73
74
    /**
75
     * Retrieve the list of names for a locale.
76
     *
77
     * @param  string  $locale
78
     * @return \Illuminate\Support\Collection
79
     */
80
    public function names(string $locale = null): Collection
81
    {
82
        return collect(PhpWeekday::getNames($this->locale($locale)));
83
    }
84
85
    /**
86
     * Parse a value and return an instance.
87
     *
88
     * @param  string|int  $value
89
     * @param  string  $locale
90
     * @return self
91
     */
92
    public function parse($value, string $locale = null): self
93
    {
94
        return new static(
95
            PhpWeekday::parse($value, $this->locale($locale))
96
        );
97
    }
98
99
    /**
100
     * Change the locale of the instance.
101
     *
102
     * @param  string  $locale
103
     * @return self
104
     */
105
    public function to(string $locale): self
106
    {
107
        $this->getInstance()->setLocale($locale);
108
109
        return $this;
110
    }
111
112
    /**
113
     * Retrieve the value of a weekday.
114
     *
115
     * @param  string  $name
116
     * @param  string  $locale
117
     * @return string
118
     */
119
    public function value(string $name, string $locale = null): int
120
    {
121
        return static::parse($name, $locale)
122
            ->getInstance()
123
            ->getValue();
124
    }
125
}
126