110 lines
1.8 KiB
PHP
110 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Questionnaire\Model;
|
|
|
|
class Result
|
|
{
|
|
protected $title;
|
|
|
|
protected $value = 0;
|
|
|
|
protected $isOut = false;
|
|
|
|
protected $info;
|
|
|
|
protected $weightings = array();
|
|
|
|
public function hydrate(array $data)
|
|
{
|
|
foreach ($data as $k => $v) {
|
|
$setter = 'set'.ucfirst($k);
|
|
|
|
if (method_exists($this, $setter)) {
|
|
$this->$setter($v);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setTitle($title)
|
|
{
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTitle()
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function setWeightings(array $weightings)
|
|
{
|
|
$this->weightings = $weightings;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getWeightings()
|
|
{
|
|
return $this->weightings;
|
|
}
|
|
|
|
public function setValue($value)
|
|
{
|
|
$this->value = (int) $value;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getValue()
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
public function setIsOut($isOut)
|
|
{
|
|
$this->isOut = (bool) $isOut;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getIsOut()
|
|
{
|
|
return $this->isOut;
|
|
}
|
|
|
|
public function isOut()
|
|
{
|
|
if (func_num_args() === 0) {
|
|
return $this->getIsOut();
|
|
}
|
|
|
|
return $this->setIsOut(func_get_arg(0));
|
|
}
|
|
|
|
public function addWeighting($weighting)
|
|
{
|
|
return $this->setValue($this->getValue() + $weighting);
|
|
}
|
|
|
|
public function setInfo($info)
|
|
{
|
|
$this->info = $info;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getInfo($locale)
|
|
{
|
|
if (null === $this->info) {
|
|
return '';
|
|
}
|
|
|
|
$file = sprintf('../app/distros/%s/%s.md', $locale, $this->info);
|
|
|
|
return file_exists($file) ? file_get_contents($file) : '';
|
|
}
|
|
}
|