Ejemplo n.º 1
0
 /**
  * This function parses the format provided by Config and sets the default formatting for getting date information
  * like day, month, year, etc..
  *
  * @throws DateTimeObjectException
  */
 private function parseDateTimeFormat()
 {
     try {
         if ($this->isNull($this->format)) {
             $this->format = self::$defaultFormat;
         }
         $str = new StringObject($this->format);
         $chunks = $str->split();
         $this->buildFormatterList();
         foreach ($chunks as $c) {
             foreach (self::$formatters as $fk => $f) {
                 if ($f->inArray($c)) {
                     $this->dateTimeFormat[$fk] = $c;
                 }
             }
         }
         $this->dateTimeFormat = new ArrayObject($this->dateTimeFormat);
     } catch (\Exception $e) {
         throw new DateTimeObjectException(DateTimeObjectException::MSG_INVALID_DATE_FORMAT, [$this->format]);
     }
 }
Ejemplo n.º 2
0
 public function testSplit2()
 {
     $s = new StringObject('a b c');
     $arr = $s->split(2);
     $this->assertSame(['a ', 'b ', 'c'], $arr->val());
 }