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:
Meritoo
2017-09-29 09:24:57 +02:00
parent 0562cb4d21
commit dbd0a65286
45 changed files with 6 additions and 2 deletions

View File

@@ -0,0 +1,397 @@
<?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: full data of participant
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
class Participant extends BaseItem
{
/**
* ID of the participant
*
* @var int
*/
private $id;
/**
* Another ID of the participant?
* Don't know where it is used.
*
* @var int
*/
private $participantId;
/**
* MP ID
*
* @var int
*/
private $mpId;
/**
* First name of the participant
*
* @var string
*/
private $firstName;
/**
* Last name of the participant
*
* @var string
*/
private $lastName;
/**
* E-mail of the participant
*
* @var string
*/
private $email;
/**
* Status of the e-mail
*
* @var string
*/
private $emailStatus;
/**
* Token of the participant
*
* @var string
*/
private $token;
/**
* Language of the participant
*
* @var string
*/
private $language;
/**
* Information if participant is blacklisted
*
* @var bool
*/
private $blacklisted;
/**
* Information if token was sent to participant/user
*
* @var bool
*/
private $sent;
/**
* Information if reminder about token was sent to participant/user
*
* @var bool
*/
private $reminderSent;
/**
* Count of sent reminders to participant/user
*
* @var int
*/
private $reminderCount;
/**
* Information if the participant has completed the survey
*
* @var bool
*/
private $completed;
/**
* Count of left uses of the token
*
* @var int
*/
private $usesLeft;
/**
* Information from which day the token is valid
*
* @var DateTime
*/
private $validFrom;
/**
* Information until which day the token is valid
*
* @var DateTime
*/
private $validUntil;
/**
* {@inheritdoc}
*/
public function setValue($property, $value)
{
switch ($property) {
case 'tid':
$this->id = (int)$value;
break;
case 'participant_id':
$this->participantId = (int)$value;
break;
case 'mpid':
$this->mpId = (int)$value;
break;
case 'firstname':
$this->firstName = trim($value);
break;
case 'lastname':
$this->lastName = trim($value);
break;
case 'email':
$this->email = trim($value);
break;
case 'emailstatus':
$this->emailStatus = trim($value);
break;
case 'token':
$this->token = trim($value);
break;
case 'language':
$this->language = trim($value);
break;
case 'blacklisted':
$this->blacklisted = 'Y' === trim($value);
break;
case 'sent':
$this->sent = 'Y' === trim($value);
break;
case 'remindersent':
$this->reminderSent = 'Y' === trim($value);
break;
case 'remindercount':
$this->reminderCount = (int)$value;
break;
case 'completed':
$this->completed = 'Y' === trim($value);
break;
case 'usesleft':
$this->usesLeft = (int)$value;
break;
case 'validfrom':
if (null === $value) {
break;
}
$this->validFrom = Date::getDateTime($value, false, 'Y-m-d H:i:s');
break;
case 'validuntil':
if (null === $value) {
break;
}
$this->validUntil = Date::getDateTime($value, false, 'Y-m-d H:i:s');
break;
}
}
/**
* Returns ID of the participant
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Returns another ID of the participant?
* Don't know where it is used.
*
* @return int
*/
public function getParticipantId()
{
return $this->participantId;
}
/**
* Returns MP ID
*
* @return int
*/
public function getMpId()
{
return $this->mpId;
}
/**
* Returns first name of the participant
*
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Returns last name of the participant
*
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* Returns e-mail of the participant
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Returns status of the e-mail
*
* @return string
*/
public function getEmailStatus()
{
return $this->emailStatus;
}
/**
* Returns token of the participant
*
* @return string
*/
public function getToken()
{
return $this->token;
}
/**
* Returns language of the participant
*
* @return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* Returns information if participant is blacklisted
*
* @return bool
*/
public function isBlacklisted()
{
return $this->blacklisted;
}
/**
* Returns information if token was sent to participant/user
*
* @return bool
*/
public function isSent()
{
return $this->sent;
}
/**
* Returns information if reminder about token was sent to participant/user
*
* @return bool
*/
public function isReminderSent()
{
return $this->reminderSent;
}
/**
* Returns count of sent reminders to participant/user
*
* @return int
*/
public function getReminderCount()
{
return $this->reminderCount;
}
/**
* Returns information if the participant has completed the survey
*
* @return bool
*/
public function isCompleted()
{
return $this->completed;
}
/**
* Returns count of left uses of the token
*
* @return int
*/
public function getUsesLeft()
{
return $this->usesLeft;
}
/**
* Returns information from which day the token is valid
*
* @return DateTime
*/
public function getValidFrom()
{
return $this->validFrom;
}
/**
* Returns information until which day the token is valid
*
* @return DateTime
*/
public function getValidUntil()
{
return $this->validUntil;
}
}

View File

@@ -0,0 +1,106 @@
<?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 Meritoo\LimeSurvey\ApiClient\Base\Result\BaseItem;
/**
* One item of the result/data: short data of one participant
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
class ParticipantShort extends BaseItem
{
/**
* ID of the participant
*
* @var int
*/
private $id;
/**
* First name of the participant
*
* @var string
*/
private $firstName;
/**
* Last name of the participant
*
* @var string
*/
private $lastName;
/**
* E-mail of the participant
*
* @var string
*/
private $email;
/**
* {@inheritdoc}
*/
public function setValue($property, $value)
{
switch ($property) {
case 'tid':
$this->id = (int)$value;
break;
case 'participant_info':
$this->firstName = trim($value['firstname']);
$this->lastName = trim($value['lastname']);
$this->email = trim($value['email']);
break;
}
}
/**
* Returns ID of the participant
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Returns first name of the participant
*
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Returns last name of the participant
*
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* Returns e-mail of the participant
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
}

View File

@@ -0,0 +1,153 @@
<?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;
/**
* One item of the result/data: full data of one question of survey
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
class Question extends QuestionShort
{
/**
* Available answers
*
* @var array
*/
private $availableAnswers;
/**
* Sub-questions
* @var array
*/
private $subQuestions;
/**
* Attributes
*
* @var array
*/
private $attributes;
/**
* Attributes in languages
*
* @var array
*/
private $attributesLanguages;
/**
* Answer's options
*
* @var array
*/
private $answerOptions;
/**
* Default value
*
* @var string
*/
private $defaultValue;
/**
* {@inheritdoc}
*/
public function setValue($property, $value)
{
parent::setValue($property, $value);
switch ($property) {
case 'available_answers':
$this->availableAnswers = $value;
break;
case 'subquestions':
$this->subQuestions = $value;
break;
case 'attributes':
$this->attributes = $value;
break;
case 'attributes_lang':
$this->attributesLanguages = $value;
break;
case 'answeroptions':
$this->answerOptions = $value;
break;
case 'defaultvalue':
$this->defaultValue = $value;
break;
}
}
/**
* Returns available answers
*
* @return array
*/
public function getAvailableAnswers()
{
return $this->availableAnswers;
}
/**
* Returns sub-questions
*
* @return array
*/
public function getSubQuestions()
{
return $this->subQuestions;
}
/**
* Returns attributes
*
* @return array
*/
public function getAttributes()
{
return $this->attributes;
}
/**
* Returns attributes in languages
*
* @return array
*/
public function getAttributesLanguages()
{
return $this->attributesLanguages;
}
/**
* Returns answer's options
*
* @return array
*/
public function getAnswerOptions()
{
return $this->answerOptions;
}
/**
* Returns default value
*
* @return string
*/
public function getDefaultValue()
{
return $this->defaultValue;
}
}

View File

@@ -0,0 +1,398 @@
<?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 Meritoo\LimeSurvey\ApiClient\Base\Result\BaseItem;
/**
* One item of the result/data: short data of one question of survey
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
class QuestionShort extends BaseItem
{
/**
* ID of the question
*
* @var int
*/
private $id;
/**
* ID of the parent question
*
* @var int
*/
private $parentId;
/**
* ID of the survey
*
* @var int
*/
private $surveyId;
/**
* ID of the group of questions
*
* @var int
*/
private $groupId;
/**
* ID of the scale
* (what does it mean?)
*
* @var int
*/
private $scaleId;
/**
* Type of the question
*
* @var string
*/
private $type;
/**
* Title of the question
*
* @var string
*/
private $title;
/**
* Content of the question
*
* @var string
*/
private $content;
/**
* Explanation of the question
*
* @var string
*/
private $contentHelp;
/**
* Regular expression
* (what does it mean? used to validate answer?)
*
* @var string
*/
private $regularExpression;
/**
* Information if type of question is other
* (what does it mean?)
*
* @var bool
*/
private $other;
/**
* Information if the question mandatory
*
* @var bool
*/
private $mandatory;
/**
* Position/Order of the question
*
* @var int
*/
private $position;
/**
* Language of the question
*
* @var string
*/
private $language;
/**
* Same as default
* (what does it mean?)
*
* @var int
*/
private $sameDefault;
/**
* Relevant equation
*
* @var string
*/
private $relevance;
/**
* Name of module
* (what does it mean?)
*
* @var string
*/
private $moduleName;
/**
* {@inheritdoc}
*/
public function setValue($property, $value)
{
switch ($property) {
case 'qid':
$this->id = (int)$value;
break;
case 'parent_qid':
$this->parentId = (int)$value;
break;
case 'sid':
$this->surveyId = (int)$value;
break;
case 'gid':
$this->groupId = (int)$value;
break;
case 'scale_id':
$this->scaleId = (int)$value;
break;
case 'type':
$this->type = trim($value);
break;
case 'title':
$this->title = trim($value);
break;
case 'question':
$this->content = trim($value);
break;
case 'help':
$this->contentHelp = trim($value);
break;
case 'preg':
if (null === $value) {
break;
}
$this->regularExpression = trim($value);
break;
case 'other':
$this->other = 'Y' === trim($value);
break;
case 'mandatory':
$this->mandatory = 'Y' === trim($value);
break;
case 'question_order':
$this->position = (int)$value;
break;
case 'language':
$this->language = trim($value);
break;
case 'same_default':
$this->sameDefault = (int)$value;
break;
case 'relevance':
$this->relevance = trim($value);
break;
case 'modulename':
if (null === $value) {
break;
}
$this->moduleName = trim($value);
break;
}
}
/**
* Returns ID of the question
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Returns ID of the parent question
*
* @return int
*/
public function getParentId()
{
return $this->parentId;
}
/**
* Returns ID of the survey
*
* @return int
*/
public function getSurveyId()
{
return $this->surveyId;
}
/**
* Returns ID of the group of questions
*
* @return int
*/
public function getGroupId()
{
return $this->groupId;
}
/**
* Returns ID of the scale
*
* @return int
*/
public function getScaleId()
{
return $this->scaleId;
}
/**
* Returns type of the question
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Returns title of the question
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Returns content of the question
*
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* Returns explanation of the question
*
* @return string
*/
public function getContentHelp()
{
return $this->contentHelp;
}
/**
* Returns regular expression
*
* @return string
*/
public function getRegularExpression()
{
return $this->regularExpression;
}
/**
* Returns information if type of question is other
*
* @return bool
*/
public function isOther()
{
return $this->other;
}
/**
* Returns information if the question mandatory
*
* @return bool
*/
public function isMandatory()
{
return $this->mandatory;
}
/**
* Returns position/Order of the question
*
* @return int
*/
public function getPosition()
{
return $this->position;
}
/**
* Returns language of the question
*
* @return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* Returns information related to same as default
*
* @return int
*/
public function getSameDefault()
{
return $this->sameDefault;
}
/**
* Returns relevant equation
*
* @return string
*/
public function getRelevance()
{
return $this->relevance;
}
/**
* Returns name of module
*
* @return string
*/
public function getModuleName()
{
return $this->moduleName;
}
}

143
src/Result/Item/Survey.php Normal file
View 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;
}
}