Small typehinting changes

This commit is contained in:
Ruben 2016-09-05 15:34:11 +01:00
parent 14b301849f
commit 322c883422
5 changed files with 27 additions and 9 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ config/*
!config/_default.php !config/_default.php
.phpintel .phpintel
/nbproject

View File

@ -47,24 +47,21 @@ class CustomJsonResponse extends JsonResponse {
* Sets the data to be sent as JSON. * Sets the data to be sent as JSON.
* *
* @param mixed $data * @param mixed $data
*
* @return JsonResponse * @return JsonResponse
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function setData($data = array()) public function setData($data = [])
{ {
$data = call_user_func($this->serializer_callback, $data); $this->data = call_user_func($this->serializer_callback, $data);
$this->data = $data;
return $this->update(); return $this->update();
} }
/** /**
* Set * Set
* @param [type] $data [description] * @param mixed $data Data to be encoded
* @return [type] [description] * @return string Json encoded string
* @throws \Exception
*/ */
public static function serializeDefault($data) { public static function serializeDefault($data) {
if (defined('HHVM_VERSION')) { if (defined('HHVM_VERSION')) {

View File

@ -24,6 +24,9 @@ class Application {
} }
private function __clone() {} private function __clone() {}
/**
* @return Application
*/
public static function getInstance() { public static function getInstance() {
if (!Application::$instance instanceof self) { if (!Application::$instance instanceof self) {
Application::$instance = new self(); Application::$instance = new self();
@ -31,10 +34,17 @@ class Application {
return Application::$instance; return Application::$instance;
} }
/**
* Get the apps config
* @return array
*/
public function getConfig() { public function getConfig() {
return $this->config; return $this->config;
} }
/**
* @return EntityManager
*/
public function getEm() { public function getEm() {
if(!$this->em) { if(!$this->em) {

View File

@ -220,7 +220,11 @@ class Game
$text = "When you had to feel " $text = "When you had to feel "
. $target->getScore() ."% " . $emotion->getName() . $target->getScore() ."% " . $emotion->getName()
." you showed " . $exaggerate . round($hit->getEmotions()->getEmotionScore($emotion),3) ."%."; ." 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)) { if(!empty($betterHit)) {
$diffs = $betterHit->getExpressions()->getDifferences($hit->getExpressions()); $diffs = $betterHit->getExpressions()->getDifferences($hit->getExpressions());
$max = max($diffs); $max = max($diffs);
@ -235,6 +239,7 @@ class Game
} }
if($diffExpression) { if($diffExpression) {
/* @var $diffExpressionText string */
$diffExpressionText = $betterHit->getExpressions()::$EXPRESSIONS_2ND_PERSON[$diffExpression]; $diffExpressionText = $betterHit->getExpressions()::$EXPRESSIONS_2ND_PERSON[$diffExpression];
$text .= " To show your empathy, you have to " . $diffExpressionText ." " . $diff . "% " . $diffText ."."; $text .= " To show your empathy, you have to " . $diffExpressionText ." " . $diff . "% " . $diffText .".";
} }

View File

@ -6,6 +6,11 @@ use EmotionHero\Tools\Position;
class HitRepository extends EntityRepository 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) { public function getBetterHit(Hit $hit) {
// we want only the slightly better hit... // we want only the slightly better hit...
$query = $this->_em->createQuery( $query = $this->_em->createQuery(