mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 10:11:49 +01:00
composer.json - move tests-related classes to "autoload-dev" section (used for development purposes only and avoid polluting the autoloader in production)
This commit is contained in:
143
src/Result/Item/Survey.php
Normal file
143
src/Result/Item/Survey.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\LimeSurvey\ApiClient\Result\Item;
|
||||
|
||||
use DateTime;
|
||||
use Meritoo\Common\Utilities\Date;
|
||||
use Meritoo\LimeSurvey\ApiClient\Base\Result\BaseItem;
|
||||
|
||||
/**
|
||||
* One item of the result/data: survey
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class Survey extends BaseItem
|
||||
{
|
||||
/**
|
||||
* ID of the survey
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* Title of the survey
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Date when the survey starts
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
private $startsAt;
|
||||
|
||||
/**
|
||||
* Date when the survey expires
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
private $expiresAt;
|
||||
|
||||
/**
|
||||
* Information if the survey is active
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $active = false;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue($property, $value)
|
||||
{
|
||||
switch ($property) {
|
||||
case 'sid':
|
||||
$this->id = (int)$value;
|
||||
break;
|
||||
|
||||
case 'surveyls_title':
|
||||
$this->title = trim($value);
|
||||
break;
|
||||
|
||||
case 'startdate':
|
||||
if (null === $value) {
|
||||
break;
|
||||
}
|
||||
|
||||
$this->startsAt = Date::getDateTime($value, false, 'Y-m-d H:i:s');
|
||||
break;
|
||||
|
||||
case 'expires':
|
||||
if (null === $value) {
|
||||
break;
|
||||
}
|
||||
|
||||
$this->expiresAt = Date::getDateTime($value, false, 'Y-m-d H:i:s');
|
||||
break;
|
||||
|
||||
case 'active':
|
||||
$this->active = 'Y' === trim($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns ID of the survey
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns title of the survey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns date when the survey starts
|
||||
*
|
||||
* @return DateTime|null
|
||||
*/
|
||||
public function getStartsAt()
|
||||
{
|
||||
return $this->startsAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns date when the survey expires
|
||||
*
|
||||
* @return DateTime|null
|
||||
*/
|
||||
public function getExpiresAt()
|
||||
{
|
||||
return $this->expiresAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if the survey is active
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user