Issues (30)

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/Service/Customer/CustomerService.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 Speicher210\Fastbill\Api\Service\Customer;
4
5
use Speicher210\Fastbill\Api\AbstractService;
6
use Speicher210\Fastbill\Api\Model\Customer;
7
8
/**
9
 * Service for customers.
10
 */
11
class CustomerService extends AbstractService
12
{
13
    /**
14
     * Get the customers.
15
     *
16
     * @param Get\RequestData|null $requestData The request data.
17
     * @return Get\ApiResponse
18
     */
19 12
    public function getCustomers(Get\RequestData $requestData = null)
20
    {
21 12
        $request = new Get\Request($requestData);
22
23 12
        $apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
24
25
        /** @var Get\Response $response */
26 12
        $response = $apiResponse->getResponse();
27 12
        foreach ($response->getCustomers() as $customer) {
28 12
            if ($customer->getBirthday() instanceof \DateTime) {
29 9
                $customer->getBirthday()->setTime(0, 0, 0);
30 9
            }
31 12
        }
32
33 12
        return $apiResponse;
34
    }
35
36
    /**
37
     * Get one customer by ID.
38
     *
39
     * @param integer $customerId The customer ID.
40
     * @return Customer|null
41
     */
42 6 View Code Duplication
    public function getCustomer($customerId)
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...
43
    {
44 6
        $requestData = new Get\RequestData();
45 6
        $requestData->setCustomerId($customerId);
46
47 6
        $customers = $this->getCustomers($requestData)->getResponse()->getCustomers();
48
49 6
        return isset($customers[0]) ? $customers[0] : null;
50
    }
51
52
    /**
53
     * Get once customer by the external ID.
54
     *
55
     * @param string $customerExternalUid The external customer ID.
56
     * @return Customer|null
57
     */
58 3 View Code Duplication
    public function getCustomerByExternalUid($customerExternalUid)
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...
59
    {
60 3
        $requestData = new Get\RequestData();
61 3
        $requestData->setCustomerExternalUid($customerExternalUid);
62
63 3
        $customers = $this->getCustomers($requestData)->getResponse()->getCustomers();
64
65 3
        return isset($customers[0]) ? $customers[0] : null;
66
    }
67
68
    /**
69
     * Update a customer.
70
     *
71
     * @param Update\RequestData $requestData The data to send.
72
     * @return Update\ApiResponse
73
     */
74 3
    public function updateCustomer(Update\RequestData $requestData)
75
    {
76 3
        $request = new Update\Request($requestData);
77
78 3
        return $this->sendRequest($request, Update\ApiResponse::class);
79
    }
80
81
    /**
82
     * Create a customer.
83
     *
84
     * @param Customer $customer The customer data to send.
85
     * @return Create\ApiResponse
86
     */
87 3
    public function createCustomer(Customer $customer)
88
    {
89 3
        $request = new Create\Request($customer);
90
91 3
        return $this->sendRequest($request, Create\ApiResponse::class);
92
    }
93
94
    /**
95
     * Delete a customer.
96
     *
97
     * @param integer $customerId The customer ID to delete.
98
     * @return Delete\ApiResponse
99
     */
100 3
    public function deleteCustomer($customerId)
101
    {
102 3
        $requestData = new Delete\RequestData($customerId);
103 3
        $request = new Delete\Request($requestData);
104
105 3
        return $this->sendRequest($request, Delete\ApiResponse::class);
106
    }
107
108
    /**
109
     * Add credits to a customer.
110
     *
111
     * @param integer $customerId The customer ID.
112
     * @param float $amount The amount of credit to add.
113
     * @return AddCredits\ApiResponse
114
     */
115 3
    public function addCredits($customerId, $amount)
116
    {
117 3
        $requestData = new AddCredits\RequestData($customerId, $amount);
118 3
        $request = new AddCredits\Request($requestData);
119
120 3
        return $this->sendRequest($request, AddCredits\ApiResponse::class);
121
    }
122
123
    /**
124
     * Add credits to a customer.
125
     *
126
     * @param integer $customerId The customer ID.
127
     * @return CreateSecureLink\ApiResponse
128
     */
129 3
    public function createSecureLink($customerId)
130
    {
131 3
        $requestData = new CreateSecureLink\RequestData($customerId);
132 3
        $request = new CreateSecureLink\Request($requestData);
133
134 3
        return $this->sendRequest($request, CreateSecureLink\ApiResponse::class);
135
    }
136
}
137