Issues (3)

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/ResultCollection.php (3 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
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the SmsGate package
7
 *
8
 * (c) SmsGate
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace SmsGate;
15
16
use SmsGate\Exception\ResultNotFoundException;
17
18
/**
19
 * The collection for store results of send sms.
20
 *
21
 * @author Vitaliy Zhuk <[email protected]>
22
 */
23
class ResultCollection implements \Iterator, \Countable
24
{
25
    /**
26
     * @var Result[]
27
     */
28
    private $results;
29
30
    /**
31
     * Constructor.
32
     *
33
     * @param Result[] ...$results
34
     */
35 6
    public function __construct(Result ...$results)
36
    {
37 6
        $this->results = $results;
0 ignored issues
show
Documentation Bug introduced by
It seems like $results of type array<integer,array<inte...bject<SmsGate\Result>>> is incompatible with the declared type array<integer,object<SmsGate\Result>> of property $results.

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...
38 6
    }
39
40
    /**
41
     * Find the result by phone
42
     *
43
     * @param Phone $phone
44
     *
45
     * @return Result
46
     *
47
     * @throws ResultNotFoundException
48
     */
49 2
    public function findByPhone(Phone $phone): Result
50
    {
51 2
        foreach ($this->results as $result) {
52 2
            if ($result->getPhone()->getValue() === $phone->getValue()) {
53 1
                return $result;
54
            }
55
        }
56
57 1
        throw new ResultNotFoundException(sprintf(
58 1
            'Not found result for phone "%s".',
59 1
            $phone
60
        ));
61
    }
62
63
    /**
64
     * Get successfully results
65
     *
66
     * @return ResultCollection
67
     */
68 View Code Duplication
    public function getSuccessfullyResults(): ResultCollection
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...
69
    {
70 1
        $successfullyResults = array_filter($this->results, function (Result $result) {
71 1
            return $result->isSuccessfully();
72 1
        });
73
74 1
        return new self(...$successfullyResults);
75
    }
76
77
    /**
78
     * Get failed results
79
     *
80
     * @return ResultCollection
81
     */
82 View Code Duplication
    public function getFailedResults(): ResultCollection
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...
83
    {
84 1
        $failedResults = array_filter($this->results, function (Result $result) {
85 1
            return $result->isFailed();
86 1
        });
87
88 1
        return new self(...$failedResults);
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94 2
    public function current(): Result
95
    {
96 2
        return current($this->results);
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102 2
    public function next(): void
103
    {
104 2
        next($this->results);
105 2
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110 1
    public function key()
111
    {
112 1
        return key($this->results);
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118 2
    public function valid(): bool
119
    {
120 2
        return key($this->results) !== null;
121
    }
122
123
    /**
124
     * {@inheritdoc}
125
     */
126 2
    public function rewind(): void
127
    {
128 2
        reset($this->results);
129 2
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134 3
    public function count(): int
135
    {
136 3
        return count($this->results);
137
    }
138
}
139