Example #1
0
 /**
  * Create a window
  */
 public static function create($title, $width, $height)
 {
     $inst = new self();
     $inst->setIsWrapped(TRUE);
     $inst->setTitle($title);
     $inst->setSize($width, $height);
     unset($inst->wrapper->{'widget'});
     return $inst;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function duplicate($name)
 {
     $clone = new self($name);
     $clone->setContent($this->content);
     $clone->setChecksum($this->checksum);
     $clone->setMetadata($this->metadata);
     $clone->setMimeType($this->mimetype);
     $clone->setSize($this->size);
     if (null !== $this->lastAccess) {
         $clone->setLastAccess($this->lastAccess);
     }
     if (null !== $this->lastModification) {
         $clone->setLastModification($this->lastModification);
     }
     return $clone;
 }
Example #3
0
 /**
  * ( excerpt from http://php.net/manual/en/splfixedarray.fromarray.php )
  *
  * Import the PHP array array in a new SplFixedArray instance
  *
  * @array      mixed   The array to import.
  * @save_indexes
  *             mixed   Try to save the numeric indexes used in the original
  *                     array.
  *
  * @return     mixed   Returns an instance of SplFixedArray containing the
  *                     array content.
  */
 public static function fromArray($array, $save_indexes = true)
 {
     $fixed_array = new self();
     if (!is_array($array)) {
         trigger_error(sprintf("SplFixedArray::fromArray() expects parameter 1 to be array," . " %s given", gettype($array)), E_WARNING);
         return $fixed_array;
     }
     if ($save_indexes) {
         $fixed_array->setSize(max(array_keys($array)) + 1);
         foreach ($array as $key => $value) {
             if (!is_numeric($key) || $key < 0) {
                 throw new InvalidArgumentException('array must contain only positive integer keys');
             }
             $fixed_array[$key] = $value;
         }
     } else {
         $fixed_array->data = array_values($array);
     }
     return $fixed_array;
 }
Example #4
0
 /**
  * ( excerpt from http://php.net/manual/en/splfixedarray.fromarray.php )
  *
  * Import the PHP array array in a new SplFixedArray instance
  *
  * @array      mixed   The array to import.
  * @save_indexes
  *             mixed   Try to save the numeric indexes used in the original
  *                     array.
  *
  * @return     mixed   Returns an instance of SplFixedArray containing the
  *                     array content.
  */
 public static function fromArray($array, $save_indexes = true)
 {
     $fixed_array = new self();
     if ($save_indexes) {
         foreach ($array as $key => $value) {
             if (!is_numeric($key) || $key < 0) {
                 throw new InvalidArgumentException('array must contain only positive integer keys');
             }
             if ($key >= $fixed_array->count()) {
                 $fixed_array->setSize($key + 1);
             }
             $fixed_array[$key] = $value;
         }
     } else {
         $fixed_array->data = array_values($array);
     }
     return $fixed_array;
 }
Example #5
0
 /**
  * Factory method.
  * Only this method can be used
  * to create this object
  *
  * @param string $email
  * @param int $size
  * @param string $fallback
  * @param string $rating
  * @return object object of this class
  */
 public static function factory($email, $size = '75', $fallback = 'wavatar', $rating = 'g')
 {
     if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new \InvalidArgumentException('Invalid value of $email: ' . $email);
     }
     if (!function_exists('curl_init') || !extension_loaded('curl')) {
         d('Your php does not have curl extension. Unable to fetch Gravatar. A dummy class will be used instead');
         return new Stub();
     }
     $o = new self($email);
     $o->setSize($size)->setRating($rating)->setFallback($fallback);
     return $o;
 }
Example #6
0
 public static function createFromStateSummary(stdClass $states, $title, array $colors)
 {
     $handledUnhandledStates = array();
     foreach ($states as $key => $value) {
         if (String::endsWith($key, '_handled') || String::endsWith($key, '_unhandled')) {
             $handledUnhandledStates[$key] = $value;
         }
     }
     $chart = new self(array_values($handledUnhandledStates), $title, $colors);
     return $chart->setSize(50)->setTitle('')->setSparklineClass('sparkline-multi');
 }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['asset_id' => null, 'url' => null, 'size' => null, 'checksum' => null], $values);
     $message->setAssetId($values['asset_id']);
     $message->setUrl($values['url']);
     $message->setSize($values['size']);
     $message->setChecksum($values['checksum']);
     return $message;
 }
Example #8
0
 /**
  * Creates an instance with data
  *
  * @param  array    $data
  * @return Resource
  */
 public static function create(array $data = array())
 {
     $defaults = array('id' => null, 'uuid' => null, 'hash' => null, 'date_created' => new DateTime(), 'data' => new IdentifiableDataContainer(array()), 'mimetype' => null, 'size' => null, 'exclusive' => false);
     $data = array_merge($defaults, $data);
     $obj = new self();
     $obj->setUuid($data['uuid']);
     $obj->setId($data['id']);
     $obj->setHash($data['hash']);
     $obj->setDateCreated($data['date_created']);
     $obj->setData($data['data']);
     $obj->setMimetype($data['mimetype']);
     $obj->setSize($data['size']);
     $obj->setExclusive($data['exclusive']);
     return $obj;
 }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['asset_id' => null, 'bundle_name' => null, 'version' => null, 'checksum' => null, 'size' => null, 'key' => null], $values);
     $message->setAssetId($values['asset_id']);
     $message->setBundleName($values['bundle_name']);
     $message->setVersion($values['version']);
     $message->setChecksum($values['checksum']);
     $message->setSize($values['size']);
     $message->setKey($values['key']);
     return $message;
 }