Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/ninja-fo.../includes/Entities
File: SimpleEntity.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace NinjaForms\Includes\Entities;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Simple entity abstract upon which all entities are built
[5] Fix | Delete
*
[6] Fix | Delete
* Entities are classes that pass well defined data honoring contracts.
[7] Fix | Delete
* Single parameters and arrays, when passed into an entity, can be relied
[8] Fix | Delete
* upon to provide the data defined by the entity, even if the original data
[9] Fix | Delete
* did not fully define values.
[10] Fix | Delete
*/
[11] Fix | Delete
class SimpleEntity implements \JsonSerializable
[12] Fix | Delete
{
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Constructs an array representation
[16] Fix | Delete
*/
[17] Fix | Delete
public function toArray(): array
[18] Fix | Delete
{
[19] Fix | Delete
$vars = get_object_vars($this);
[20] Fix | Delete
$array = [];
[21] Fix | Delete
foreach ($vars as $property => $value) {
[22] Fix | Delete
if (is_object($value) && is_callable([$value, 'toArray'])) {
[23] Fix | Delete
$value = $value->toArray();
[24] Fix | Delete
}
[25] Fix | Delete
$array[$property] = $value;
[26] Fix | Delete
}
[27] Fix | Delete
return $array;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Sets data for json_encode
[32] Fix | Delete
*
[33] Fix | Delete
* @return void
[34] Fix | Delete
*/
[35] Fix | Delete
#[\ReturnTypeWillChange]
[36] Fix | Delete
public function jsonSerialize()
[37] Fix | Delete
{
[38] Fix | Delete
return $this->toArray();
[39] Fix | Delete
}
[40] Fix | Delete
/**
[41] Fix | Delete
* Magic method getter for properties
[42] Fix | Delete
*
[43] Fix | Delete
* @param string $name
[44] Fix | Delete
* @return void
[45] Fix | Delete
*/
[46] Fix | Delete
public function __get($name)
[47] Fix | Delete
{
[48] Fix | Delete
$getter = 'get' . ucfirst($name);
[49] Fix | Delete
if (method_exists($this, $getter)) {
[50] Fix | Delete
return call_user_func([$this, $getter]);
[51] Fix | Delete
}
[52] Fix | Delete
if (property_exists($this, $name)) {
[53] Fix | Delete
return $this->$name;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
if (isset($this->$name)) {
[57] Fix | Delete
return $this->$name;
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Magic method setter for properties
[63] Fix | Delete
*
[64] Fix | Delete
* Usually does not support setting undefined properties, but this class is
[65] Fix | Delete
* enabling that, although it is kept as a separate command in case it must
[66] Fix | Delete
* be modified. This is because field definitions can have an undetermined
[67] Fix | Delete
* collection of settings and this class will enable setting of all those
[68] Fix | Delete
* values, while maintaining the ability to define sets and gets that filter
[69] Fix | Delete
* values for proper types.
[70] Fix | Delete
*
[71] Fix | Delete
* @param string $name
[72] Fix | Delete
* @param mixed $value
[73] Fix | Delete
* @return SimpleEntity
[74] Fix | Delete
*/
[75] Fix | Delete
public function __set($name, $value)
[76] Fix | Delete
{
[77] Fix | Delete
$setter = 'set' . ucfirst($name);
[78] Fix | Delete
if (method_exists($this, $setter)) {
[79] Fix | Delete
try {
[80] Fix | Delete
return call_user_func([$this, $setter], $value);
[81] Fix | Delete
} catch (\TypeError $e) {
[82] Fix | Delete
// Do not set invalid type
[83] Fix | Delete
return $this;
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
if (property_exists($this, $name)) {
[88] Fix | Delete
$this->$name = $value;
[89] Fix | Delete
return $this;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
$this->$name = $value;
[93] Fix | Delete
[94] Fix | Delete
return $this;
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function