GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
BanEntry Class Reference

Public Member Functions

 __construct ($name)
 
 getName ()
 
 getCreated ()
 
 setCreated (\DateTime $date)
 
 getSource ()
 
 setSource ($source)
 
 getExpires ()
 
 setExpires ($date)
 
 hasExpired ()
 
 getReason ()
 
 setReason ($reason)
 
 getString ()
 

Static Public Member Functions

static fromString ($str)
 

Static Public Attributes

static $format = "Y-m-d H:i:s O"
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $name)

BanEntry constructor.

Parameters
$name
42  {
43  $this->name = strtolower($name);
44  $this->creationDate = new \DateTime();
45  }

Member Function Documentation

◆ fromString()

static fromString (   $str)
static
Parameters
string$str
Returns
BanEntry
142  {
143  if(strlen($str) < 2){
144  return null;
145  }else{
146  $str = explode("|", trim($str));
147  $entry = new BanEntry(trim(array_shift($str)));
148  if(count($str) > 0){
149  $datetime = \DateTime::createFromFormat(self::$format, array_shift($str));
150  if(!($datetime instanceof \DateTime)){
151  MainLogger::getLogger()->alert("Error parsing date for BanEntry for player \"" . $entry->getName() . "\", the format may be invalid!");
152  return $entry;
153  }
154  $entry->setCreated($datetime);
155  if(count($str) > 0){
156  $entry->setSource(trim(array_shift($str)));
157  if(count($str) > 0){
158  $expire = trim(array_shift($str));
159  if(strtolower($expire) !== "forever" and strlen($expire) > 0){
160  $entry->setExpires(\DateTime::createFromFormat(self::$format, $expire));
161  }
162  if(count($str) > 0){
163  $entry->setReason(trim(array_shift($str)));
164  }
165  }
166  }
167  }
168 
169  return $entry;
170  }
171  }

◆ getCreated()

getCreated ( )
Returns
57  {
58  return $this->creationDate;
59  }

◆ getExpires()

getExpires ( )
Returns
85  {
86  return $this->expirationDate;
87  }

◆ getName()

getName ( )
Returns
string
50  : string{
51  return $this->name;
52  }

◆ getReason()

getReason ( )
Returns
string
108  {
109  return $this->reason;
110  }

◆ getSource()

getSource ( )
Returns
string
71  {
72  return $this->source;
73  }

◆ getString()

getString ( )
Returns
string
122  {
123  $str = "";
124  $str .= $this->getName();
125  $str .= "|";
126  $str .= $this->getCreated()->format(self::$format);
127  $str .= "|";
128  $str .= $this->getSource();
129  $str .= "|";
130  $str .= $this->getExpires() === null ? "Forever" : $this->getExpires()->format(self::$format);
131  $str .= "|";
132  $str .= $this->getReason();
133 
134  return $str;
135  }

◆ hasExpired()

hasExpired ( )
Returns
bool
99  {
100  $now = new \DateTime();
101 
102  return $this->expirationDate === null ? false : $this->expirationDate < $now;
103  }

◆ setCreated()

setCreated ( \DateTime  $date)
Parameters
\DateTime$date
64  {
65  $this->creationDate = $date;
66  }

◆ setExpires()

setExpires (   $date)
Parameters
\DateTime$date
92  {
93  $this->expirationDate = $date;
94  }

◆ setReason()

setReason (   $reason)
Parameters
$reason
115  {
116  $this->reason = $reason;
117  }

◆ setSource()

setSource (   $source)
Parameters
$source
78  {
79  $this->source = $source;
80  }

Field Documentation

◆ $format

$format = "Y-m-d H:i:s O"
static

The documentation for this class was generated from the following file: