mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 18:11:50 +01:00
Base class for one item - add class constructor & allow to set values directly in the constructor
This commit is contained in:
@@ -16,13 +16,32 @@ namespace Meritoo\LimeSurvey\ApiClient\Base\Result;
|
||||
*/
|
||||
abstract class BaseItem
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $data (optional) Data to set in properties of the item
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
{
|
||||
$this->setValues($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets given value in given property
|
||||
*
|
||||
* @param string $property Name of property to set the value
|
||||
* @param mixed $value Value to set in property
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function setValue($property, $value);
|
||||
|
||||
/**
|
||||
* Sets values in each property of the item
|
||||
*
|
||||
* @param array $data Data to set in properties of the item
|
||||
* @return $this
|
||||
*/
|
||||
public function setValues($data)
|
||||
private function setValues(array $data)
|
||||
{
|
||||
/*
|
||||
* Oops, no data
|
||||
@@ -40,13 +59,4 @@ abstract class BaseItem
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets given value in given property
|
||||
*
|
||||
* @param string $property Name of property to set the value
|
||||
* @param mixed $value Value to set in property
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function setValue($property, $value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user