GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (23)

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/Currency.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
namespace RafaHernandez\LaravelIntl;
4
5
use CommerceGuys\Intl\Currency\CurrencyRepository;
6
use CommerceGuys\Intl\Formatter\CurrencyFormatter;
7
use CommerceGuys\Intl\NumberFormat\NumberFormatRepository;
8
use Illuminate\Support\Arr;
9
use RafaHernandez\LaravelIntl\Concerns\WithLocales;
10
use RafaHernandez\LaravelIntl\Contracts\Intl;
11
12
class Currency extends Intl
13
{
14
    use WithLocales;
15
16
    /**
17
     * Loaded localized currency data.
18
     *
19
     * @var array
20
     */
21
    protected $data;
22
23
    /**
24
     * Array of localized currency formatters.
25
     *
26
     * @var array
27
     */
28
    protected $formatters;
29
30
    /**
31
     * Alias of get().
32
     *
33
     * @param string $currencyCode
34
     *
35
     * @return string
36
     */
37 12
    public function name($currencyCode)
38
    {
39 12
        return $this->get($currencyCode);
40
    }
41
42
    /**
43
     * Get a localized record by key.
44
     *
45
     * @param string $currencyCode
46
     *
47
     * @return string
48
     */
49 15
    public function get($currencyCode)
50
    {
51 15
        return $this->data()->get($currencyCode)->getName();
52
    }
53
54
    /**
55
     * The currency repository.
56
     *
57
     * @return \CommerceGuys\Intl\Currency\CurrencyRepository
58
     */
59 33 View Code Duplication
    protected function data()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

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

Loading history...
60
    {
61 33
        $key = $this->getLocalesKey(
62 33
            $locale = $this->getLocale(),
63 33
            $fallbackLocale = $this->getFallbackLocale()
64
        );
65
66 33
        if (!isset($this->data[$key])) {
67 33
            $this->data[$key] = new CurrencyRepository($locale, $fallbackLocale);
68
        }
69
70 33
        return $this->data[$key];
71
    }
72
73
    /**
74
     * Get the formatter's key.
75
     *
76
     * @param string $locale
77
     * @param string $fallbackLocale
78
     *
79
     * @return string
80
     */
81 33
    protected function getLocalesKey($locale, $fallbackLocale)
82
    {
83 33
        return implode('|', [
84 33
            $locale,
85 33
            $fallbackLocale,
86
        ]);
87
    }
88
89
    /**
90
     * Get the symbol of the given currency.
91
     *
92
     * @param string $currencyCode
93
     *
94
     * @return string
95
     */
96 3
    public function symbol($currencyCode)
97
    {
98 3
        return $this->data()->get($currencyCode)->getSymbol();
99
    }
100
101
    /**
102
     * Format a number.
103
     *
104
     * @param string|int|float $number
105
     * @param string           $currencyCode
106
     * @param array            $options
107
     *
108
     * @return mixed|string
109
     */
110 12
    public function format($number, $currencyCode, $options = [])
111
    {
112 12
        return $this->formatter()->format($number, $currencyCode,
113 12
            $this->mergeOptions($options)
114
        );
115
    }
116
117
    /**
118
     * The current number formatter.
119
     *
120
     * @return \CommerceGuys\Intl\Formatter\CurrencyFormatter
121
     */
122 18 View Code Duplication
    protected function formatter()
123
    {
124 18
        $key = $this->getLocalesKey(
125 18
            $locale = $this->getLocale(),
126 18
            $fallbackLocale = $this->getFallbackLocale()
127
        );
128
129 18
        if (!isset($this->formatters[$key])) {
130 18
            $this->formatters[$key] = new CurrencyFormatter(
131 18
                new NumberFormatRepository($fallbackLocale),
132 18
                $this->data(),
133 18
                ['locale' => $locale]
134
            );
135
        }
136
137 18
        return $this->formatters[$key];
138
    }
139
140
    /**
141
     * Merges the options array.
142
     *
143
     * @param array $options
144
     * @param array $defaults
145
     *
146
     * @return array
147
     */
148 18
    protected function mergeOptions(array $options, array $defaults = [])
149
    {
150 18
        Arr::forget($options, 'locale');
151
152 18
        return $defaults + $options;
153
    }
154
155
    /**
156
     * Format a number.
157
     *
158
     * @param string|int|float $number
159
     * @param string           $currencyCode
160
     * @param array            $options
161
     *
162
     * @return mixed|string
163
     */
164 3
    public function formatAccounting($number, $currencyCode, $options = [])
165
    {
166 3
        return $this->formatter()->format($number, $currencyCode,
167 3
            $this->mergeOptions($options, ['style' => 'accounting'])
168
        );
169
    }
170
171
    /**
172
     * Parse a localized currency string into a number.
173
     *
174
     * @param string $number
175
     * @param string $currencyCode
176
     * @param array  $options
177
     *
178
     * @return mixed|string
179
     */
180 3
    public function parse($number, $currencyCode, $options = [])
181
    {
182 3
        return $this->formatter()->parse($number, $currencyCode,
183 3
            $this->mergeOptions($options)
184
        );
185
    }
186
187
    /**
188
     * Get all localized records.
189
     *
190
     * @return array
191
     */
192 3
    public function all()
193
    {
194 3
        return $this->data()->getList();
195
    }
196
}
197