Created
May 30, 2013 10:58
-
-
Save clemblanco/5677103 to your computer and use it in GitHub Desktop.
Tests if a Picture entity has already been voted by a specific User.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Tests if a Picture entity has already been voted by a specific User. | |
* | |
* @param Innteger $userId The User ID. | |
* @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise. | |
*/ | |
public function hasBeenVotedBy($userId) | |
{ | |
$predicate = function($key, $element) use ($userId){ | |
return $element->getUser()->getId() === intval($userId); | |
}; | |
return $this->votes->exists($predicate); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment