diff --git a/.gitignore b/.gitignore index bbe19c7..84d0900 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ config/* !config/_default.php .phpintel +/nbproject diff --git a/src/Api/CustomJsonResponse.php b/src/Api/CustomJsonResponse.php index 4697daa..20b5e4d 100644 --- a/src/Api/CustomJsonResponse.php +++ b/src/Api/CustomJsonResponse.php @@ -47,24 +47,21 @@ class CustomJsonResponse extends JsonResponse { * Sets the data to be sent as JSON. * * @param mixed $data - * * @return JsonResponse - * * @throws \InvalidArgumentException */ - public function setData($data = array()) + public function setData($data = []) { - $data = call_user_func($this->serializer_callback, $data); - - $this->data = $data; + $this->data = call_user_func($this->serializer_callback, $data); return $this->update(); } /** * Set - * @param [type] $data [description] - * @return [type] [description] + * @param mixed $data Data to be encoded + * @return string Json encoded string + * @throws \Exception */ public static function serializeDefault($data) { if (defined('HHVM_VERSION')) { diff --git a/src/Application.php b/src/Application.php index dace9e6..068951c 100644 --- a/src/Application.php +++ b/src/Application.php @@ -24,6 +24,9 @@ class Application { } private function __clone() {} + /** + * @return Application + */ public static function getInstance() { if (!Application::$instance instanceof self) { Application::$instance = new self(); @@ -31,10 +34,17 @@ class Application { return Application::$instance; } + /** + * Get the apps config + * @return array + */ public function getConfig() { return $this->config; } + /** + * @return EntityManager + */ public function getEm() { if(!$this->em) { diff --git a/src/Models/Game.php b/src/Models/Game.php index c21151d..437b574 100644 --- a/src/Models/Game.php +++ b/src/Models/Game.php @@ -220,7 +220,11 @@ class Game $text = "When you had to feel " . $target->getScore() ."% " . $emotion->getName() ." you showed " . $exaggerate . round($hit->getEmotions()->getEmotionScore($emotion),3) ."%."; - $betterHit = Application::getInstance()->getEm()->getRepository(Hit::class)->getBetterHit($lowest_scoring_hit); + + /* @var $hitRepo HitRepository */ + $hitRepo = Application::getInstance()->getEm()->getRepository(Hit::class); + $betterHit = $hitRepo->getBetterHit($lowest_scoring_hit); + if(!empty($betterHit)) { $diffs = $betterHit->getExpressions()->getDifferences($hit->getExpressions()); $max = max($diffs); @@ -235,6 +239,7 @@ class Game } if($diffExpression) { + /* @var $diffExpressionText string */ $diffExpressionText = $betterHit->getExpressions()::$EXPRESSIONS_2ND_PERSON[$diffExpression]; $text .= " To show your empathy, you have to " . $diffExpressionText ." " . $diff . "% " . $diffText ."."; } diff --git a/src/Models/HitRepository.php b/src/Models/HitRepository.php index 2aff45c..dd79d52 100644 --- a/src/Models/HitRepository.php +++ b/src/Models/HitRepository.php @@ -6,6 +6,11 @@ use EmotionHero\Tools\Position; class HitRepository extends EntityRepository { + /** + * + * @param \EmotionHero\Models\Hit $hit + * @return Hit The hit that is considered better than the given one (used for hints) + */ public function getBetterHit(Hit $hit) { // we want only the slightly better hit... $query = $this->_em->createQuery(