setReason() public méthode

public setReason ( $reason )
Exemple #1
0
 /**
  * @param string    $target
  * @param string    $reason
  * @param \DateTime $expires
  * @param string    $source
  *
  * @return BanEntry
  */
 public function addBan($target, $reason = null, $expires = null, $source = null)
 {
     $entry = new BanEntry($target);
     $entry->setSource($source != null ? $source : $entry->getSource());
     $entry->setExpires($expires);
     $entry->setReason($reason != null ? $reason : $entry->getReason());
     $this->list[$entry->getName()] = $entry;
     $this->save();
     return $entry;
 }
Exemple #2
0
 /**
  * @param string $str
  *
  * @return BanEntry
  */
 public static function fromString($str)
 {
     if (strlen($str) < 2) {
         return null;
     } else {
         $str = explode("|", trim($str));
         $entry = new BanEntry(trim(array_shift($str)));
         if (count($str) > 0) {
             $datetime = \DateTime::createFromFormat(self::$format, array_shift($str));
             if (!$datetime instanceof \DateTime) {
                 MainLogger::getLogger()->alert("Error parsing date for BanEntry for player \"" . $entry->getName() . "\", the format may be invalid!");
                 return $entry;
             }
             $entry->setCreated($datetime);
             if (count($str) > 0) {
                 $entry->setSource(trim(array_shift($str)));
                 if (count($str) > 0) {
                     $expire = trim(array_shift($str));
                     if (strtolower($expire) !== "forever" and strlen($expire) > 0) {
                         $entry->setExpires(\DateTime::createFromFormat(self::$format, $expire));
                     }
                     if (count($str) > 0) {
                         $entry->setReason(trim(array_shift($str)));
                     }
                 }
             }
         }
         return $entry;
     }
 }