Issues (5)

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/MetaData/BaseMetaData.php (2 issues)

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 SeoHelper\MetaData;
4
5
use InvalidArgumentException;
6
7
class BaseMetaData
8
{
9
    private $data = [];
10
11
    private $aliases = [];
12
13 27
    public function __call($name, $arguments)
14
    {
15 27
        if (substr($name, 0, 3) === 'get') {
16 15
            $propertyName = $this->createPropertyName(str_replace('get', '', $name));
17 15
            return $this->get($propertyName);
18 27 View Code Duplication
        } elseif (substr($name, 0, 3) == 'set') {
0 ignored issues
show
This code seems to be duplicated across 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...
19 15
            $propertyName = $this->createPropertyName(str_replace('set', '', $name));
20 15
            return $this->set($propertyName, $arguments[0]);
21 24
        } elseif (substr($name, 0, 3) == 'add') {
22 18
            $propertyName = $this->createPropertyName(str_replace('add', '', $name));
23 18
            return $this->add($propertyName, $arguments[0]);
24 6 View Code Duplication
        } elseif (substr($name, 0, 5) == 'reset') {
0 ignored issues
show
This code seems to be duplicated across 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...
25 3
            $propertyName = $this->createPropertyName(str_replace('reset', '', $name));
26 3
            return $this->reset($propertyName, isset($arguments[0]) ? $arguments[0] : null);
27
        }
28 3
        throw new InvalidArgumentException("Method '$name' not found");
29
    }
30
31
    /**
32
     * @param string $key
33
     * @param string|array $value
34
     * @return BaseMetaData
35
     */
36 18
    final public function set($key, $value)
37
    {
38 18
        if (!is_array($value)) {
39 18
            $value = [$value];
40 6
        }
41 18
        foreach ($this->findAliases($key) as $alias) {
42 18
            $this->data[$alias] = $value;
43 6
        }
44 18
        return $this;
45
    }
46
47
    /**
48
     * @param string $key
49
     * @param string|array|null $newValue
50
     * @return BaseMetaData
51
     */
52 3
    final public function reset($key, $newValue = null)
53
    {
54 3
        if ($newValue !== null) {
55 3
            return $this->set($key, $newValue);
56
        }
57
58 3
        foreach ($this->findAliases($key) as $alias) {
59 3
            unset($this->data[$alias]);
60 1
        }
61 3
        return $this;
62
    }
63
64
    /**
65
     * @param string $key
66
     * @param string|array $value
67
     * @return BaseMetaData
68
     */
69 18
    final public function add($key, $value)
70
    {
71 18
        if (!is_array($value)) {
72 18
            $value = [$value];
73 6
        }
74 18
        foreach ($this->findAliases($key) as $alias) {
75 18
            if (!isset($this->data[$alias])) {
76 18
                $this->data[$alias] = [];
77 6
            }
78 18
            $this->data[$alias] = array_merge($this->data[$alias], $value);
79 6
        }
80 18
        return $this;
81
    }
82
83
    /**
84
     * @param string $key
85
     * @return array|false all data if $key is null or data for $key as array or false if $key is not set in data
86
     */
87 27
    final public function get($key = null)
88
    {
89 27
        if ($key === null) {
90 21
            return $this->data;
91
        }
92 18
        return isset($this->data[$key]) ? $this->data[$key] : false;
93
    }
94
95
    /**
96
     * alias(es) for type
97
     * for example title => [og:title, twitter:title], in this case there is no need to set all types, because they will be set automatically with main type
98
     * @param string $type
99
     * @param string|array $alias
100
     */
101 3
    final public function alias($type, $alias)
102
    {
103 3
        if (!isset($this->aliases[$type])) {
104 3
            $this->aliases[$type] = [];
105 1
        }
106 3
        if (!is_array($alias)) {
107 3
            $this->aliases[$type][] = $alias;
108 3
            return $this;
109
        }
110
111 3
        $this->aliases[$type] = array_merge($this->aliases[$type], $alias);
112 3
        return $this;
113
    }
114
115 24
    private function createPropertyName($camelCase)
116
    {
117 24
        $length = strlen($camelCase);
118 24
        $lowerCamelCase = lcfirst($camelCase);
119 24
        $propertyName = '';
120 24
        for ($i = 0; $i < $length; $i++) {
121 24
            if ($lowerCamelCase[$i] == strtoupper($lowerCamelCase[$i])) {
122 15
                $propertyName .= ':';
123 5
            }
124 24
            $propertyName .= strtolower($lowerCamelCase[$i]);
125 8
        }
126 24
        return $propertyName;
127
    }
128
129 27
    private function findAliases($key)
130
    {
131 27
        $aliases = isset($this->aliases[$key]) ? $this->aliases[$key] : [];
132 27
        return array_merge([$key], $aliases);
133
    }
134
}
135