Issues (194)

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/Bpost/Order/Box/Option/Insurance.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
namespace Bpost\BpostApiClient\Bpost\Order\Box\Option;
3
4
use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException;
5
6
/**
7
 * bPost Insurance class
8
 *
9
 * @author    Tijs Verkoyen <[email protected]>
10
 * @version   3.0.0
11
 * @copyright Copyright (c), Tijs Verkoyen. All rights reserved.
12
 * @license   BSD License
13
 */
14
class Insurance extends Option
15
{
16
17
    const INSURANCE_TYPE_BASIC_INSURANCE = 'basicInsurance';
18
    const INSURANCE_TYPE_ADDITIONAL_INSURANCE = 'additionalInsurance';
19
20
    const INSURANCE_AMOUNT_UP_TO_2500_EUROS = 2;
21
    const INSURANCE_AMOUNT_UP_TO_5000_EUROS = 3;
22
    const INSURANCE_AMOUNT_UP_TO_7500_EUROS = 4;
23
    const INSURANCE_AMOUNT_UP_TO_10000_EUROS = 5;
24
    const INSURANCE_AMOUNT_UP_TO_12500_EUROS = 6;
25
    const INSURANCE_AMOUNT_UP_TO_15000_EUROS = 7;
26
    const INSURANCE_AMOUNT_UP_TO_17500_EUROS = 8;
27
    const INSURANCE_AMOUNT_UP_TO_20000_EUROS = 9;
28
    const INSURANCE_AMOUNT_UP_TO_22500_EUROS = 10;
29
    const INSURANCE_AMOUNT_UP_TO_25000_EUROS = 11;
30
31
    /**
32
     * @var string
33
     */
34
    private $type;
35
36
    /**
37
     * @var string
38
     */
39
    private $value;
40
41
    /**
42
     * @return array
43
     */
44 2
    public static function getPossibleTypeValues()
45
    {
46
        return array(
47 2
            self::INSURANCE_TYPE_BASIC_INSURANCE,
48 2
            self::INSURANCE_TYPE_ADDITIONAL_INSURANCE,
49 2
        );
50
    }
51
52
    /**
53
     * @param string $type
54
     * @throws BpostInvalidValueException
55
     */
56 2
    public function setType($type)
57
    {
58
59 2
        if (!in_array($type, self::getPossibleTypeValues())) {
60 1
            throw new BpostInvalidValueException('type', $type, self::getPossibleTypeValues());
61
        }
62
63 2
        $this->type = $type;
64 2
    }
65
66
    /**
67
     * @return string
68
     */
69 1
    public function getType()
70
    {
71 1
        return $this->type;
72
    }
73
74
    /**
75
     * @param string $value
76
     * @throws BpostInvalidValueException
77
     */
78 2
    public function setValue($value)
79
    {
80 2
        if (!in_array($value, self::getPossibleValueValues())) {
81 1
            throw new BpostInvalidValueException('value', $value, self::getPossibleValueValues());
82
        }
83
84 1
        $this->value = $value;
85 1
    }
86
87
    /**
88
     * @return string
89
     */
90 1
    public function getValue()
91
    {
92 1
        return $this->value;
93
    }
94
95
    /**
96
     * @return array
97
     */
98 2 View Code Duplication
    public static function getPossibleValueValues()
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...
99
    {
100
        return array(
101 2
            self::INSURANCE_AMOUNT_UP_TO_2500_EUROS,
102 2
            self::INSURANCE_AMOUNT_UP_TO_5000_EUROS,
103 2
            self::INSURANCE_AMOUNT_UP_TO_7500_EUROS,
104 2
            self::INSURANCE_AMOUNT_UP_TO_10000_EUROS,
105 2
            self::INSURANCE_AMOUNT_UP_TO_12500_EUROS,
106 2
            self::INSURANCE_AMOUNT_UP_TO_15000_EUROS,
107 2
            self::INSURANCE_AMOUNT_UP_TO_17500_EUROS,
108 2
            self::INSURANCE_AMOUNT_UP_TO_20000_EUROS,
109 2
            self::INSURANCE_AMOUNT_UP_TO_22500_EUROS,
110 2
            self::INSURANCE_AMOUNT_UP_TO_25000_EUROS,
111 2
        );
112
    }
113
114
    /**
115
     * @param string      $type
116
     * @param string|null $value
117
     *
118
     * @throws BpostInvalidValueException
119
     */
120 2
    public function __construct($type, $value = null)
121
    {
122 2
        $this->setType($type);
123 2
        if ($value !== null) {
124 2
            $this->setValue($value);
125 1
        }
126 1
    }
127
128
    /**
129
     * Return the object as an array for usage in the XML
130
     *
131
     * @param  \DomDocument $document
132
     * @param  string       $prefix
133
     * @return \DomElement
134
     */
135 1
    public function toXML(\DOMDocument $document, $prefix = 'common')
136
    {
137 1
        $tagName = 'insured';
138 1
        if ($prefix !== null) {
139 1
            $tagName = $prefix . ':' . $tagName;
140 1
        }
141 1
        $insured = $document->createElement($tagName);
142
143 1
        $tagName = $this->getType();
144 1
        if ($prefix !== null) {
145 1
            $tagName = $prefix . ':' . $tagName;
146 1
        }
147 1
        $insurance = $document->createElement($tagName);
148 1
        $insured->appendChild($insurance);
149
150 1
        if ($this->getValue() !== null) {
151 1
            $insurance->setAttribute('value', $this->getValue());
152 1
        }
153
154 1
        return $insured;
155
    }
156
}
157