Issues (6)

Security Analysis    not enabled

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/BundleItems/BundleItem.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 LaravelLangBundler\BundleItems;
4
5
class BundleItem
6
{
7
    /**
8
     * Lang id of translation.
9
     *
10
     * @var string
11
     */
12
    protected $id;
13
14
    /**
15
     * Namespace of id. The last value in the id.
16
     *
17
     * @var string
18
     */
19
    protected $namespace;
20
21
    /**
22
     * Key to be used in return array.
23
     *
24
     * @var string
25
     */
26
    protected $key;
27
28
    /**
29
     * Collection of valid parameters.
30
     *
31
     * @var Collection
32
     */
33
    protected $parameters = [];
34
35
    /**
36
     * The translation value from lang. Returned in return array.
37
     *
38
     * @var mixed
39
     */
40
    protected $value = '';
41
42
    /**
43
     * If not null, trans_choice will be called and value passed as countable.
44
     *
45
     * @var null|int|Countable
46
     */
47
    protected $choice = null;
48
49
    /**
50
     * Construct.
51
     *
52
     * @param string $id
53
     */
54
    public function __construct($id)
55
    {
56
        $namespace = $this->setNamespace($id);
57
58
        $this->setKey($namespace);
59
60
        $this->setId($id);
61
    }
62
63
    /**
64
     * Return the value of choice. If not null, trans_choice will be called.
65
     *
66
     * @return int|Countable|null
67
     */
68
    public function hasChoice()
69
    {
70
        return $this->choice;
71
    }
72
73
    /**
74
     * Return the translation key for return array.
75
     *
76
     * @return string
77
     */
78
    public function getKey()
79
    {
80
        return $this->key;
81
    }
82
83
    /**
84
     * Get the Laravel lang id of translation.
85
     *
86
     * @return string
87
     */
88
    public function getId()
89
    {
90
        return $this->id;
91
    }
92
93
    /**
94
     * Return the namespace for the translation.
95
     *
96
     * @return string
97
     */
98
    public function getNamespace()
99
    {
100
        return $this->namespace;
101
    }
102
103
    /**
104
     * Return array of valid parameters.
105
     *
106
     * @return array
107
     */
108
    public function getParameters()
109
    {
110
        return $this->parameters->all();
111
    }
112
113
    /**
114
     * Return the final key/value pair array.
115
     *
116
     * @return array
117
     */
118
    public function getReturnArray()
119
    {
120
        return [$this->getKey() => $this->getValue()];
121
    }
122
123
    /**
124
     * Return the value.
125
     *
126
     * @return mixed
127
     */
128
    public function getValue()
129
    {
130
        return $this->value;
131
    }
132
133
    /**
134
     * Set choice value on object.
135
     *
136
     * @param int|Countable $value
137
     */
138
    public function setChoice($value)
139
    {
140
        $this->choice = $value;
141
    }
142
143
    /**
144
     * Set only valid parameters. If namespaced, only parameters with
145
     * translation namespace will be set.
146
     *
147
     * @param array $parameters
148
     */
149
    public function setParameters($parameters)
150
    {
151
        $this->parameters = collect($parameters)->mapWithKeys(function ($value, $key) {
0 ignored issues
show
Documentation Bug introduced by
It seems like collect($parameters)->ma...ray($key => $value); }) of type object<Illuminate\Support\Collection> is incompatible with the declared type object<LaravelLangBundler\BundleItems\Collection> of property $parameters.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
152
            if (!$key = $this->getNamespacedKey($key)) {
153
                return [];
154
            }
155
156
            if ($key === 'choice') {
157
                $this->setChoice($value);
158
            }
159
160
            return [$key => $value];
161
        });
162
    }
163
164
    /**
165
     * Get only global and keys with this item's namespace.
166
     *
167
     * @param string $key
168
     *
169
     * @return string|null
170
     */
171
    protected function getNamespacedKey($key)
172
    {
173
        $keyArray = explode('.', $key);
174
175
        if (count($keyArray) !== 2) {
176
            return $key;
177
        } elseif ($keyArray[0] === $this->getNamespace()) {
178
            return $keyArray[1];
179
        }
180
    }
181
182
    /**
183
     * Set the lang value on the object.
184
     *
185
     * @param mixed $value
186
     */
187
    public function setValue($value)
188
    {
189
        $this->value = $value;
190
191
        return $this;
192
    }
193
194
    /**
195
     * Set the translation namespace on the object.
196
     */
197
    protected function setNamespace($id)
198
    {
199
        return $this->namespace = collect(explode('.', $id))->last();
200
    }
201
202
    /**
203
     * Get key for translation value.
204
     *
205
     * @return string
206
     */
207
    protected function setKey($namespace)
208
    {
209
        $transformMethod = config('lang-bundler.key_transform');
210
211
        if ($transformMethod === 'none') {
212
            return $this->key = $namespace;
213
        }
214
215
        return $this->key = $transformMethod($namespace);
216
    }
217
218
    /**
219
     * Prefix the translation id with global_key_namespace, if set.
220
     *
221
     * @param string $id
222
     *
223
     * @return string
224
     */
225
    protected function setId($id)
226
    {
227
        $prefix = config('lang-bundler.global_key_namespace');
228
229
        if (!empty($prefix)) {
230
            $id = $prefix.'.'.$id;
231
        }
232
233
        $this->id = $id;
234
    }
235
}
236