Skip to content

Instantly share code, notes, and snippets.

@gCardinal
Created February 10, 2016 21:27
Show Gist options
  • Save gCardinal/1d869c86c4bf4f7e7b90 to your computer and use it in GitHub Desktop.
Save gCardinal/1d869c86c4bf4f7e7b90 to your computer and use it in GitHub Desktop.
<?php
// Nous vérifions que l'utilisateur est bien du bon type pour ne pas appeler getLastActivity() sur un objet autre objet User
if ($user instanceof User && $user->getLastActivity() < $delay) {
$user->setActiveNow();
$this->em->flush($user);
}
// Pourquoi tu met un commentaire? Fais une méthode pour me l'expliquer.
function userIsRightType($user User, $delay) {
return $user instanceof User && $user->getLastActivity() < $delay;
}
if ($this->userIsRightType($user, $delay)) {
$user->setActiveNow();
$this->em->flush($user);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment