Issues (15)

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/Set/HashSet.php (5 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 namespace BuildR\Collection\Set;
2
3
use BuildR\Collection\Collection\AbstractCollection;
4
use BuildR\Collection\Exception\CollectionException;
5
6
/**
7
 * Set type (Collection implementation)
8
 * Sets only store scalar types
9
 *
10
 * BuildR PHP Framework
11
 *
12
 * @author Zoltán Borsos <[email protected]>
13
 * @package Collection
14
 * @subpackage Set
15
 *
16
 * @copyright    Copyright 2015, Zoltán Borsos.
17
 * @license      https://github.com/Zolli/BuildR/blob/master/LICENSE.md
18
 * @link         https://github.com/Zolli/BuildR
19
 */
20
class HashSet extends AbstractCollection implements SetInterface {
21
22
    /**
23
     * Set constructor.
24
     *
25
     * @param null|array $values
26
     */
27 31
    public function __construct($values = NULL) {
28 31
        if(is_array($values)) {
29 11
            $this->addAll($values);
30 11
        }
31 31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 27
    public function contains($element) {
37 27
        return (array_search($element, $this->data, TRUE) === FALSE) ? FALSE : TRUE;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 10 View Code Duplication
    public function containsAll($elements) {
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...
44 10
        $elements = $this->collectionToArray($elements);
45
46 10
        $result = TRUE;
47
48 10
        foreach($elements as $item) {
49 10
            if($this->contains($item) === FALSE) {
50 5
                $result = FALSE;
51
52 5
                break;
53
            }
54 10
        }
55
56 10
        return $result;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 6 View Code Duplication
    public function containsAny($elements) {
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...
63 6
        $elements = $this->collectionToArray($elements);
64
65 6
        foreach($elements as $item) {
66 6
            if($this->contains($item) === TRUE) {
67 5
                return TRUE;
68
            }
69 6
        }
70
71 6
        return FALSE;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 6
    public function equals(SetInterface $collection) {
78
        //First check the size, if this not equals the tow collection
79
        //not be identical
80 6
        if($collection->size() !== $this->size()) {
81 1
            return FALSE;
82
        }
83
84
        //Use strict comparison to check arrays are equals
85
        //(Values and orders)
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86 5
        return $collection->toArray() === $this->data;
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92 31
    public function add($element) {
93 31
        if(!is_scalar($element)) {
94 4
            throw CollectionException::nonScalarTypeGiven(gettype($element));
95
        }
96
97 27
        if(!$this->contains($element)) {
98 27
            $this->data[] = $element;
99 27
        }
100 27
    }
101
102
    /**
103
     * {@inheritdoc}
104
     */
105 25
    public function addAll($elements) {
106 25
        $elements = $this->collectionToArray($elements);
107
108 25
        foreach($elements as $item) {
109 25
            $this->add($item);
110 25
        }
111 25
    }
112
113
    /**
114
     * {@inheritdoc}
115
     */
116 2
    public function remove($element) {
117 2
        if(($index = array_search($element, $this->data)) !== FALSE) {
118 2
            unset($this->data[$index]);
119
120 2
            return TRUE;
121
        }
122
123 2
        return FALSE;
124
    }
125
126
    /**
127
     * {@inheritdoc}
128
     */
129 1 View Code Duplication
    public function removeAll($elements) {
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...
130 1
        $elements = $this->collectionToArray($elements);
131
132 1
        $result = FALSE;
133
134 1
        foreach($elements as $item) {
135 1
            if($this->remove($item) === TRUE) {
136 1
                $result = TRUE;
137 1
            }
138 1
        }
139
140 1
        return $result;
141
    }
142
143
    /**
144
     * {@inheritdoc}
145
     */
146 1
    public function retainAll($elements) {
147 1
        $elements = $this->collectionToArray($elements);
148
149 1
        $result = FALSE;
150
151 1 View Code Duplication
        foreach($this->data as $index => $data) {
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...
152 1
            if(array_search($data, $elements) === FALSE) {
153 1
                unset($this->data[$index]);
154
155 1
                $result = TRUE;
156 1
            }
157 1
        }
158
159 1
        return $result;
160
    }
161
162
}
163