Issues (4)

Security Analysis    not enabled

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/MoslemPray.php (2 issues)

1
<?php
2
3
namespace Ianrizky\MoslemPray;
4
5
use Ianrizky\MoslemPray\Drivers\AbstractDriver;
6
use Ianrizky\MoslemPray\Drivers\MyQuran;
7
use Illuminate\Support\Arr;
8
use Illuminate\Support\Traits\ForwardsCalls;
9
use InvalidArgumentException;
10
11
/**
12
 * @method static \Ianrizky\MoslemPray\Drivers\MyQuran myquran(array $config = []) Create an instance of the PrayerTimes driver.
13
 * @method static \Ianrizky\MoslemPray\Contracts\Response\HasPrayerTime getPrayerTime(mixed $city, \Illuminate\Support\Carbon|string|null $date = null) Return prayer time based on the given city and date.
14
 * @method static \Ianrizky\MoslemPray\Contracts\Response\HasPrayerTimeCollection getPrayerTimePerMonth(mixed $city, \Illuminate\Support\Carbon|string|int|null $year = null, int|null $month = null) Return list of prayer time based on the given city and month.
15
 *
16
 * @see \Ianrizky\MoslemPray\Contracts\Driverable
17
 */
18
class MoslemPray
19
{
20 1
    use ForwardsCalls;
21
22
    /**
23
     * Driver instance object.
24
     *
25
     * @var \Ianrizky\MoslemPray\Drivers\AbstractDriver
26
     */
27
    protected $driver;
28
29
    /**
30
     * List of available driver name.
31
     *
32
     * @var array
33
     */
34
    public const DRIVERS = [
35
        'myquran' => MyQuran::class,
36
    ];
37
38
    /**
39
     * Default driver class name.
40
     *
41
     * @var string
42
     */
43
    public static $defaultDriverName = 'myquran';
44
45
    /**
46
     * Create a new instance class.
47
     *
48
     * @param  string|array|null  $driverName
49
     * @param  array  $config
50
     * @return void
51
     */
52 12
    public function __construct($driverName = null, array $config = [])
53
    {
54 12
        if (is_array($driverName)) {
55
            $driverName = $this->getDriverNameFromConfig($driverName);
56
57
            $config = Arr::except($config, 'driver');
58 12
        } elseif (is_null($driverName)) {
59 12
            $driverName = static::$defaultDriverName;
60
        }
61
62 12
        $this->driver = static::createDriverInstance($driverName, $config);
63 12
    }
64
65
    /**
66
     * Return driver name value from given config.
67
     *
68
     * @param  array  $config
69
     * @return string
70
     *
71
     * @throws \InvalidArgumentException
72
     */
73
    protected function getDriverNameFromConfig(array $config): string
74
    {
75
        $driverName = $config['driver'] ?? null;
76
77
        if (!static::isDriverAvailable($driverName)) {
78
            throw new InvalidArgumentException('Driver name is unidentified');
79
        }
80
81
        return $driverName;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $driverName could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
82
    }
83
84
    /**
85
     * Determine whether the given driver name is available or not.
86
     *
87
     * @param  string|null  $name
88
     * @return bool
89
     */
90 12
    public static function isDriverAvailable(?string $name): bool
91
    {
92 12
        return in_array($name, array_keys(static::DRIVERS), true);
93
    }
94
95
    /**
96
     * Create driver instance based on given driver name.
97
     *
98
     * @param  string  $driverName
99
     * @param  array  $config
100
     * @return \Ianrizky\MoslemPray\Drivers\AbstractDriver
101
     *
102
     * @throws \InvalidArgumentException
103
     */
104 12
    public static function createDriverInstance(string $driverName, array $config = []): AbstractDriver
105
    {
106 12
        if (static::isDriverAvailable($driverName)) {
107 12
            $driver = static::DRIVERS[$driverName];
108
109 12
            return new $driver($config);
110
        }
111
112
        throw new InvalidArgumentException("Driver [$driverName] is not supported.");
113
    }
114
115
    /**
116
     * Dynamically handle calls to the class.
117
     *
118
     * @param  string  $method
119
     * @param  array  $parameters
120
     * @return mixed
121
     */
122 12
    public function __call($method, $parameters)
123
    {
124 12
        if (static::isDriverAvailable($method)) {
125 12
            return static::createDriverInstance($method, ...$parameters);
0 ignored issues
show
$parameters is expanded, but the parameter $config of Ianrizky\MoslemPray\Mosl...:createDriverInstance() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

125
            return static::createDriverInstance($method, /** @scrutinizer ignore-type */ ...$parameters);
Loading history...
126
        }
127
128
        return $this->forwardCallTo($this->driver, $method, $parameters);
129
    }
130
131
    /**
132
     * Dynamically handle static calls to the class.
133
     *
134
     * @param  string  $method
135
     * @param  array  $parameters
136
     * @return mixed
137
     */
138 12
    public static function __callStatic($method, $parameters)
139
    {
140 12
        return (new static)->{$method}(...$parameters);
141
    }
142
}
143