Small typehinting changes
This commit is contained in:
parent
14b301849f
commit
322c883422
5 changed files with 27 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ config/*
|
|||
!config/_default.php
|
||||
.phpintel
|
||||
|
||||
/nbproject
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 .".";
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue