Issues (118)

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/Lodash/Support/Declensions.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
declare(strict_types=1);
4
5
namespace Longman\LaravelLodash\Support;
6
7
use InvalidArgumentException;
8
9
use function in_array;
10
use function is_null;
11
12
abstract class Declensions
13
{
14
    /** @link https://ka.wikipedia.org/wiki/%E1%83%91%E1%83%A0%E1%83%A3%E1%83%9C%E1%83%94%E1%83%91%E1%83%90 */
15
    public const DECLENSION_1 = 1; // სახელობითი
16
    public const DECLENSION_2 = 2; // მოთხრობითი
17
    public const DECLENSION_3 = 3; // მიცემითი
18
    public const DECLENSION_4 = 4; // ნათესაობითი
19
    public const DECLENSION_5 = 5; // მოქმედებითი
20
    public const DECLENSION_6 = 6; // ვითარებითი
21
    public const DECLENSION_7 = 7; // წოდებითი
22
23
    private static array $declensionRules = [
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
24
        self::DECLENSION_1 => [ // სახელობითი
25
            '*' => 'ი',
26
        ],
27
        self::DECLENSION_2 => [ // მოთხრობითი
28
            '*' => 'მა',
29
        ],
30
        self::DECLENSION_3 => [ // მიცემითი
31
            'ადმინისტრაცია' => 'ადმინისტრაციას',
32
            'თანამშრომელი'  => 'თანამშრომელს',
33
            'ინჟინერი'      => 'ინჟინერს',
34
            'ოფიცერი'       => 'ოფიცერს',
35
            'ბიბლიოთეკა'    => 'ბიბლიოთეკას',
36
            'დამლაგებელი'   => 'დამლაგებელს',
37
            'ბუღალტერი'     => 'ბუღალტერს',
38
            'ად'            => 'ადს',
39
            'ან'            => 'ანს',
40
            'ამ'            => 'ამს',
41
            'ბა'            => 'ბას',
42
            'გე'            => 'გეს',
43
            'დე'            => 'დეს',
44
            'დი'            => 'დის',
45
            'ვა'            => 'ვას',
46
            'ვი'            => 'ვს',
47
            'ია'            => 'იას',
48
            'კა'            => 'კას',
49
            'კი'            => 'კს',
50
            'კო'            => 'კოს',
51
            'ლა'            => 'ლას',
52
            'ლი'            => 'ლს',
53
            'ლე'            => 'ლეს',
54
            'ნი'            => 'ნს',
55
            'რი'            => 'რს',
56
            'სი'            => 'სს',
57
            'ტი'            => 'ტს',
58
            'უა'            => 'უას',
59
            'ში'            => 'შს',
60
            'ცი'            => 'ცს',
61
            'ძე'            => 'ძეს',
62
            'წე'            => 'წეს',
63
            'ხი'            => 'ხს',
64
            '*'             => 'ს',
65
        ],
66
        self::DECLENSION_4 => [ // ნათესაობითი
67
            'ადმინისტრაცია' => 'ადმინისტრაციის',
68
            'თანამშრომელი'  => 'თანამშრომლის',
69
            'ინჟინერი'      => 'ინჟინრის',
70
            'ოფიცერი'       => 'ოფიცრის',
71
            'ბიბლიოთეკა'    => 'ბიბლიოთეკის',
72
            'დამლაგებელი'   => 'დამლაგებლის',
73
            'ბუღალტერი'     => 'ბუღალტრის',
74
            'ად'            => 'ადის',
75
            'ან'            => 'ანის',
76
            'ამ'            => 'ამის',
77
            'ბა'            => 'ბის',
78
            'გე'            => 'გის',
79
            'დე'            => 'დის',
80
            'დი'            => 'დის',
81
            'ვა'            => 'ვას',
82
            'ვი'            => 'ვის',
83
            'ია'            => 'იას',
84
            'კა'            => 'კას',
85
            'კი'            => 'კის',
86
            'კო'            => 'კოს',
87
            'ლა'            => 'ლის',
88
            'ლი'            => 'ლის',
89
            'ლე'            => 'ლის',
90
            'ნი'            => 'ნის',
91
            'რი'            => 'რის',
92
            'სი'            => 'სის',
93
            'ტი'            => 'ტის',
94
            'უა'            => 'უას',
95
            'ში'            => 'შის',
96
            'ცი'            => 'ცის',
97
            'ძე'            => 'ძის',
98
            'წე'            => 'წის',
99
            'ხი'            => 'ხის',
100
            '*'             => 'ს', // ის
101
        ],
102
        self::DECLENSION_5 => [ // მოქმედებითი
103
            '*' => 'ით',
104
        ],
105
        self::DECLENSION_6 => [ // ვითარებითი
106
            '*' => 'ად',
107
        ],
108
        self::DECLENSION_7 => [ // წოდებითი
109
            '*' => 'ო',
110
        ],
111
    ];
112
113 32
    public static function getAvailableDeclensions(): array
114
    {
115 32
        return [self::DECLENSION_1, self::DECLENSION_2, self::DECLENSION_3, self::DECLENSION_4, self::DECLENSION_5, self::DECLENSION_6, self::DECLENSION_7];
116
    }
117
118 32
    public static function applyDeclension(string $word, int $declension): string
119
    {
120 32
        if (! in_array($declension, self::getAvailableDeclensions(), true)) {
121
            throw new InvalidArgumentException('Declension "' . $declension . '" is invalid');
122
        }
123
124 32
        $rules = self::$declensionRules[$declension];
125 32
        $turnedWord = null;
126 32
        foreach ($rules as $suffix1 => $suffix2) {
127 32
            if (Str::substr($word, -Str::length($suffix1)) === $suffix1) {
128 31
                $turnedWord = Str::substr($word, 0, -Str::length($suffix1)) . $suffix2;
129 31
                break;
130
            }
131
        }
132
133 32
        if (is_null($turnedWord)) {
134 1
            $turnedWord = $word . $rules['*'];
135
        }
136
137 32
        return $turnedWord;
138
    }
139
}
140