Example #1
0
 public static function parse(&$src)
 {
     $result = array();
     foreach (Tag::anyhow($src)->in("enclosure") as $in) {
         $src = str_replace($in->plain(), "", $src);
         $o = new self();
         $o->url($in->inParam("url"));
         $o->type($in->inParam("type"));
         $o->length($in->inParam("length"));
         $result[] = $o;
     }
     return $result;
 }
Example #2
0
 public function parse_list($response)
 {
     if ($response === "N;") {
         throw new Exception("Invalid data");
     }
     $result = array();
     foreach (unserialize($response) as $re) {
         $obj = new self();
         $obj->language($re["language"]);
         $obj->id($re["id"]);
         $obj->url($re["url"]);
         $obj->title($re["title"]);
         $obj->body($re["body"]);
         $obj->length($re["length"]);
         $obj->redirect($re["redirect"]);
         $obj->strict($re["strict"]);
         $obj->datetime($re["datetime"]);
         $result[] = $obj;
     }
     return $result;
 }
Example #3
0
 /**
  * Tests if this string starts with the specified prefix beginning at specified index.
  * @param String|string $prefix characters to search
  * @param int $toffset default to zero
  * @return boolean true if this string starts with specified prefix, false otherwise.
  */
 public function startsWith($prefix, $toffset = 0)
 {
     $temp = substr($this->str, 0, ($this->length() - 1) * -1);
     if (!$prefix instanceof self) {
         $prefix = new self($prefix);
     }
     $endIndex = $prefix->length();
     $substr = $this->substring(0, $endIndex);
     return $substr->equalsIgnoreCase($prefix);
 }
Example #4
0
 public function pad($padchar, $padlen, $type = STR_PAD_LEFT)
 {
     if (self::$isMbstringLoaded) {
         $filllen = $padlen - $this->length();
         if ($filllen < 1) {
             return $this;
         } else {
             $padChar = new self($padchar);
             if ($type === STR_PAD_LEFT || $type === STR_PAD_RIGHT) {
                 if (($_len = $padChar->length()) === 1) {
                     $padChar->repeat($filllen);
                 } elseif ($_len !== $filllen) {
                     if ($filllen < $_len) {
                         $padChar->set($padChar->substring(0, $filllen));
                     } else {
                         $padChar->repeat(floor($filllen / $_len));
                         if (($rem = $filllen % $_len) !== 0) {
                             $padChar->append($padChar->substring(0, $rem));
                         }
                     }
                 }
                 if ($type === STR_PAD_LEFT) {
                     $this->string = $padChar . $this->string;
                 } else {
                     $this->string .= $padChar;
                 }
             } elseif ($type === STR_PAD_BOTH) {
                 $this->pad($padchar, (int) floor($filllen / 2) + $this->length(), STR_PAD_LEFT);
                 $this->pad($padchar, $padlen, STR_PAD_RIGHT);
             } else {
                 $message = __METHOD__ . "() invalid pad type. Use STR_PAD_LEFT or STR_PAD_RIGHT, STR_PAD_BOTH.";
                 throw new Sabel_Exception_InvalidArgument($message);
             }
         }
     } else {
         $this->string = str_pad($this->string, $padlen, $padchar, $type);
     }
     return $this;
 }