Issues (14)

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/Object/Traits/HasObject.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 20 and the first side effect is on line 13.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Joomla! common library.
4
 *
5
 * @copyright  Copyright (C) 2017 Roberto Segura López, Inc. All rights reserved.
6
 * @license    GNU/GPL 2, http://www.gnu.org/licenses/gpl-2.0.htm
7
 */
8
9
namespace Phproberto\Joomla\Object\Traits;
10
11
use Phproberto\Joomla\Object\Object;
12
13 1
defined('JPATH_PLATFORM') || die;
14
15
/**
16
 * Classes that have an associated object.
17
 *
18
 * @since  __DEPLOY_VERSION__
19
 */
20
trait HasObject
21
{
22
	/**
23
	 * Associated object.
24
	 *
25
	 * @var  \Phproberto\Joomla\Object\Object
26
	 */
27
	protected $object;
28
29
	/**
30
	 * Set value of an object property.
31
	 *
32
	 * @param   string  $property  Name of the property to set
33
	 * @param   mixed   $value     Value to assign
34
	 *
35
	 * @return  self
36
	 */
37 1
	public function assign($property, $value)
38
	{
39 1
		if (null === $this->object)
40
		{
41 1
			$this->object = new Object;
42
		}
43
44 1
		$this->object->assign($property, $value);
45
46 1
		return $this;
47
	}
48
49
	/**
50
	 * Bind data to the object.
51
	 *
52
	 * @param   array  $data  Data to bind
53
	 *
54
	 * @return  self
55
	 */
56 2
	public function bind(array $data)
57
	{
58 2
		if (null === $this->object)
59
		{
60 1
			$this->object = new Object;
61
		}
62
63 2
		$this->object->bind($data);
64
65 2
		return $this;
66
	}
67
68
	/**
69
	 * Retrieve all the values of the object.
70
	 *
71
	 * @return  array
72
	 */
73 1
	public function data()
74
	{
75 1
		return $this->object()->data();
76
	}
77
78
	/**
79
	 * Get property of the object
80
	 *
81
	 * @param   string  $property  Name of the property to retrieve
82
	 * @param   mixed   $default   Default value if property does not exist
83
	 *
84
	 * @return  mixed
85
	 */
86 1
	public function get($property, $default = null)
87
	{
88 1
		return $this->object()->get($property, $default);
89
	}
90
91
	/**
92
	 * Check if the object has a property.
93
	 *
94
	 * @param   string  $property  Name of the property to check for
95
	 *
96
	 * @return  boolean
97
	 */
98 1
	public function has($property)
99
	{
100 1
		return $this->object()->has($property);
101
	}
102
103
	/**
104
	 * Load object.
105
	 *
106
	 * @return  self
107
	 */
108 4
	public function loadObject()
109
	{
110 4
		$this->object = new Object($this->loadObjectData());
111
112 4
		return $this;
113
	}
114
115
	/**
116
	 * Load object data.
117
	 *
118
	 * @return  array
119
	 */
120
	abstract protected function loadObjectData();
121
122
	/**
123
	 * Get the associated object.
124
	 *
125
	 * @return  Entity
126
	 */
127 4
	public function object()
128
	{
129 4
		if (null === $this->object)
130
		{
131 4
			$this->loadObject();
132
		}
133
134 4
		return clone $this->object;
135
	}
136
137
	/**
138
	 * Set the object.
139
	 *
140
	 * @param   Object  $object  Value to assign
141
	 *
142
	 * @return  self
143
	 */
144 1
	public function setObject(Object $object)
145
	{
146 1
		$this->object = $object;
147
148 1
		return $this;
149
	}
150
151
	/**
152
	 * Unassign an object property.
153
	 *
154
	 * @param   string  $property  Name of the property to set
155
	 *
156
	 * @return  self
157
	 */
158 1
	public function unassign($property)
159
	{
160 1
		if (null === $this->object)
161
		{
162 1
			$this->object = new Object;
163
		}
164
165 1
		$this->object->unassign($property);
166
167 1
		return $this;
168
	}
169
}
170