/** * Get log object based on creation time and creator of the object * * @return midgardmvc_helper_location_log */ function seek_log_object($person = null, $time = null) { if (is_integer($person) || is_string($person)) { $person_guid = $person; } elseif (is_null($person)) { $person_guid = $this->object->metadata->creator; // TODO: Use metadata.authors? } else { $person_guid = $person->guid; } if (is_null($time)) { $time = $this->object->metadata->published; } $person = new midgard_person($person_guid); $qb = midgardmvc_helper_location_log::new_query_builder(); $qb->add_constraint('person', '=', $person->id); $qb->add_constraint('date', '<=', $time); $qb->add_order('date', 'DESC'); $qb->set_limit(1); $matches = $qb->execute(); if (count($matches) > 0) { return $matches[0]; } return null; }
/** * Add a filter specific to this writer. * * @param Zend_Log_Filter_Interface $filter * @return void */ public function addFilter($filter) { if (is_integer($filter)) { $filter = new Zend_Log_Filter_Priority($filter); } $this->_filters[] = $filter; }
/** * Create destination object * * @param Zend_Pdf_Page|integer $page Page object or page number * @param float $left Left edge of displayed page * @param float $top Top edge of displayed page * @param float $zoom Zoom factor * @return Zend_Pdf_Destination_Zoom * @throws Zend_Pdf_Exception */ public static function create($page, $left = null, $top = null, $zoom = null) { $destinationArray = new Zend_Pdf_Element_Array(); if ($page instanceof Zend_Pdf_Page) { $destinationArray->items[] = $page->getPageDictionary(); } else { if (is_integer($page)) { $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page); } else { require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.'); } } $destinationArray->items[] = new Zend_Pdf_Element_Name('XYZ'); if ($left === null) { $destinationArray->items[] = new Zend_Pdf_Element_Null(); } else { $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left); } if ($top === null) { $destinationArray->items[] = new Zend_Pdf_Element_Null(); } else { $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top); } if ($zoom === null) { $destinationArray->items[] = new Zend_Pdf_Element_Null(); } else { $destinationArray->items[] = new Zend_Pdf_Element_Numeric($zoom); } return new Zend_Pdf_Destination_Zoom($destinationArray); }
/** * Adds an error. * * This method merges sfValidatorErrorSchema errors with the current instance. * * @param sfValidatorError $error An sfValidatorError instance * @param string $name The error name */ public function addError(sfValidatorError $error, $name = null) { if (is_null($name) || is_integer($name)) { if ($error instanceof sfValidatorErrorSchema) { $this->addErrors($error); } else { $this->globalErrors[] = $error; $this->errors[] = $error; } } else { if (!isset($this->namedErrors[$name]) && !$error instanceof sfValidatorErrorSchema) { $this->namedErrors[$name] = $error; $this->errors[$name] = $error; } else { if (!isset($this->namedErrors[$name])) { $this->namedErrors[$name] = new sfValidatorErrorSchema($error->getValidator()); $this->errors[$name] = new sfValidatorErrorSchema($error->getValidator()); } else { if (!$this->namedErrors[$name] instanceof sfValidatorErrorSchema) { $current = $this->namedErrors[$name]; $this->namedErrors[$name] = new sfValidatorErrorSchema($current->getValidator()); $this->errors[$name] = new sfValidatorErrorSchema($current->getValidator()); $method = $current instanceof sfValidatorErrorSchema ? 'addErrors' : 'addError'; $this->namedErrors[$name]->{$method}($current); $this->errors[$name]->{$method}($current); } } $method = $error instanceof sfValidatorErrorSchema ? 'addErrors' : 'addError'; $this->namedErrors[$name]->{$method}($error); $this->errors[$name]->{$method}($error); } } $this->updateCode(); $this->updateMessage(); }
function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success) { if (empty($value)) { if (is_array($value)) { $this->log(LOG_INFO, "Setting empty array for key '{$key}'"); } else { if (is_null($value)) { $this->log(LOG_INFO, "Setting null value for key '{$key}'"); } else { if (is_string($value)) { $this->log(LOG_INFO, "Setting empty string for key '{$key}'"); } else { if (is_integer($value)) { $this->log(LOG_INFO, "Setting integer 0 for key '{$key}'"); } else { $this->log(LOG_INFO, "Setting empty value '{$value}' for key '{$key}'"); } } } } } else { $this->log(LOG_INFO, "Setting non-empty value for key '{$key}'"); } return true; }
protected function getProperties($object) { $reflClass = new \ReflectionClass($object); $codeAnnotation = $this->annotationReader->getClassAnnotation($reflClass, Segment::class); if (!$codeAnnotation) { throw new AnnotationMissing(sprintf("Missing @Segment annotation for class %", $reflClass->getName())); } $properties = [$codeAnnotation->value]; foreach ($reflClass->getProperties() as $propRefl) { $propRefl->setAccessible(true); /** @var SegmentPiece $isSegmentPiece */ $isSegmentPiece = $this->annotationReader->getPropertyAnnotation($propRefl, SegmentPiece::class); if ($isSegmentPiece) { if (!$isSegmentPiece->parts) { $properties[$isSegmentPiece->position] = $propRefl->getValue($object); } else { $parts = $isSegmentPiece->parts; $value = $propRefl->getValue($object); $valuePieces = []; foreach ($parts as $key => $part) { if (is_integer($key)) { $partName = $part; } else { $partName = $key; } $valuePieces[] = isset($value[$partName]) ? $value[$partName] : null; } $properties[$isSegmentPiece->position] = $this->weedOutEmpty($valuePieces); } } } $properties = $this->weedOutEmpty($properties); return $properties; }
/** * Create destination object * * @param \Zend\Pdf\Page|integer $page Page object or page number * @param float $left Left edge of displayed page * @param float $top Top edge of displayed page * @param float $zoom Zoom factor * @return \Zend\Pdf\Destination\Zoom * @throws \Zend\Pdf\Exception\ExceptionInterface */ public static function create($page, $left = null, $top = null, $zoom = null) { $destinationArray = new InternalType\ArrayObject(); if ($page instanceof Pdf\Page) { $destinationArray->items[] = $page->getPageDictionary(); } elseif (is_integer($page)) { $destinationArray->items[] = new InternalType\NumericObject($page); } else { throw new Exception\InvalidArgumentException('$page parametr must be a \\Zend\\Pdf\\Page object or a page number.'); } $destinationArray->items[] = new InternalType\NameObject('XYZ'); if ($left === null) { $destinationArray->items[] = new InternalType\NullObject(); } else { $destinationArray->items[] = new InternalType\NumericObject($left); } if ($top === null) { $destinationArray->items[] = new InternalType\NullObject(); } else { $destinationArray->items[] = new InternalType\NumericObject($top); } if ($zoom === null) { $destinationArray->items[] = new InternalType\NullObject(); } else { $destinationArray->items[] = new InternalType\NumericObject($zoom); } return new self($destinationArray); }
/** * Object constructor * * @param Zend_Pdf_Element $val * @param integer $objNum * @param integer $genNum * @param Zend_Pdf_ElementFactory $factory * @throws Zend_Pdf_Exception */ public function __construct(Zend_Pdf_Element $val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory) { if ($val instanceof self) { require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('Object number must not be an instance of Zend_Pdf_Element_Object.'); } if ( !(is_integer($objNum) && $objNum > 0) ) { require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('Object number must be positive integer.'); } if ( !(is_integer($genNum) && $genNum >= 0) ) { require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('Generation number must be non-negative integer.'); } $this->_value = $val; $this->_objNum = $objNum; $this->_genNum = $genNum; $this->_factory = $factory; $this->setParentObject($this); $factory->registerObject($this, $objNum . ' ' . $genNum); }
/** * Stringifies any provided value. * * @param mixed $value * @param boolean $exportObject * * @return string */ public function stringify($value, $exportObject = true) { if (is_array($value)) { if (range(0, count($value) - 1) === array_keys($value)) { return '[' . implode(', ', array_map(array($this, __FUNCTION__), $value)) . ']'; } $stringify = array($this, __FUNCTION__); return '[' . implode(', ', array_map(function ($item, $key) use($stringify) { return (is_integer($key) ? $key : '"' . $key . '"') . ' => ' . call_user_func($stringify, $item); }, $value, array_keys($value))) . ']'; } if (is_resource($value)) { return get_resource_type($value) . ':' . $value; } if (is_object($value)) { return $exportObject ? ExportUtil::export($value) : sprintf('%s:%s', get_class($value), spl_object_hash($value)); } if (true === $value || false === $value) { return $value ? 'true' : 'false'; } if (is_string($value)) { $str = sprintf('"%s"', str_replace("\n", '\\n', $value)); if (50 <= strlen($str)) { return substr($str, 0, 50) . '"...'; } return $str; } if (null === $value) { return 'null'; } return (string) $value; }
/** * Validate the error code, and if applicable, return an Exception to be thrown. * @return * \OhUpload\Validate\Exception\UnknownInvalidErrorCodeException * \OhUpload\Validate\Exception\MaximumFileSizeExceededException * \OhUpload\Validate\Exception\NoFileUploadedException * \OhUpload\Validate\Exception\TmpFolderMissingException * \OhUpload\Validate\Exception\FailedToWriteToDiskException * \OhUpload\Validate\Exception\ExtensionStoppedUploadException * boolean true */ public function isValid() { $code = @$this->file['error']; if (!is_integer($code)) { return new UnknownInvalidErrorCodeException('Upload error code was not an integer. Got "' . gettype($code) . '"'); } switch ($code) { case 0: return true; case 1: return new MaximumFileSizeExceededException('The uploaded file exceeds the upload_max_filesize directive in php.ini.'); break; case 2: return new MaximumFileSizeExceededException('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'); break; case 4: return new NoFileUploadedException('No file was uploaded.'); break; case 6: return new TmpFolderMissingException('Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.'); break; case 7: return new FailedToWriteToDiskException('Failed to write file to disk. Introduced in PHP 5.1.0.'); break; case 8: return new ExtensionStoppedUploadException('A PHP extension stopped the file upload. PHP does not provide a way to ascertain which ' . 'extension caused the file upload to stop; examining the list of loaded extensions with ' . 'phpinfo() may help. Introduced in PHP 5.2.0.'); break; default: break; } return new UnknownInvalidErrorCodeException('Unhandled error code detected. Received: "' . $code . '"'); }
function wppb_changeDefaultAvatar($avatar, $id_or_email, $size, $default, $alt) { global $wpdb; /* Get user info. */ if (is_object($id_or_email)) { $my_user_id = $id_or_email->user_id; } elseif (is_numeric($id_or_email)) { $my_user_id = $id_or_email; } elseif (!is_integer($id_or_email)) { $user_info = get_user_by_email($id_or_email); $my_user_id = $user_info->ID; } else { $my_user_id = $id_or_email; } $arraySettingsPresent = get_option('wppb_custom_fields', 'not_found'); if ($arraySettingsPresent != 'not_found') { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $value) { if ($value['item_type'] == 'avatar') { $customUserAvatar = get_user_meta($my_user_id, 'resized_avatar_' . $value['id'], true); if ($customUserAvatar != '' || $customUserAvatar != null) { $avatar = "<img alt='{$alt}' src='{$customUserAvatar}' class='avatar avatar-{$value['item_options']} photo avatar-default' height='{$size}' width='{$size}' />"; } } } } return $avatar; }
/** * Calculate the link meta-data for paging purposes, return an array with paging information * * @param integer $limit * @param integer $offset * @param integer $total_rows The total amount of objects * * @return array */ public static function calculatePagingHeaders($limit, $offset, $total_rows) { $paging = array(); // Check if limit and offset are integers if (!is_integer((int) $limit) || !is_integer((int) $offset)) { \App::abort(400, "Please make sure limit and offset are integers."); } // Calculate the paging parameters and pass them with the data object if ($offset + $limit < $total_rows) { $paging['next'] = array($limit + $offset, $limit); $last_page = round($total_rows / $limit, 1); $last_full_page = round($total_rows / $limit, 0); if ($last_page - $last_full_page > 0) { $paging['last'] = array($last_full_page * $limit, $limit); } else { $paging['last'] = array(($last_full_page - 1) * $limit, $limit); } } if ($offset > 0 && $total_rows > 0) { $previous = $offset - $limit; if ($previous < 0) { $previous = 0; } $paging['previous'] = array($previous, $limit); } return $paging; }
/** * A user has replied to a conversation. * * @param \Cake\Event\Event $event The event that was fired. * * @return bool */ protected function _conversationReply(Event $event) { if (!is_integer($event->data['conversation_id'])) { return false; } $this->Conversations = TableRegistry::get('Conversations'); $this->Users = TableRegistry::get('Users'); $conversation = $this->Conversations->find()->where(['Conversations.id' => $event->data['conversation_id']])->select(['id', 'user_id', 'title', 'last_message_id'])->first(); $sender = $this->Users->find('medium')->where(['Users.id' => $event->data['sender_id']])->first(); //Check if this user hasn't already a notification. (Prevent for spam) $hasReplied = $this->Notifications->find()->where(['Notifications.foreign_key' => $conversation->id, 'Notifications.type' => $event->data['type'], 'Notifications.user_id' => $event->data['participant']->user->id])->first(); if (!is_null($hasReplied)) { $hasReplied->data = serialize(['sender' => $sender, 'conversation' => $conversation]); $hasReplied->is_read = 0; $this->Notifications->save($hasReplied); } else { $data = []; $data['user_id'] = $event->data['participant']->user->id; $data['type'] = $event->data['type']; $data['data'] = serialize(['sender' => $sender, 'conversation' => $conversation]); $data['foreign_key'] = $conversation->id; $entity = $this->Notifications->newEntity($data); $this->Notifications->save($entity); } return true; }
/** * Generate a [salted] hash. * * $salt can be: * false - a random will be generated * integer - a random with specified length will be generated * string * * @param string $password * @param mixed $salt * @return string */ public function getHash($password, $salt = false) { if (is_integer($salt)) { $salt = $this->_helper->getRandomString($salt); } return $salt === false ? $this->hash($password) : $this->hash($salt . $password) . ':' . $salt; }
public function testMuxGetId() { $mux = new \Pux\Mux(); $id = $mux->getId(); ok(is_integer($id)); is($id, $mux->getId()); }
/** * Send email to user * * Send an email to a site user. Using the given view file and data * * @access public * @param mixed $user User email or ID * @param string $subject Email subject * @param string $view View file to use * @param array $data Variable replacement array * @return boolean Whether the email was sent */ function send($user = NULL, $subject = 'No Subject', $view = NULL, $data = array()) { if (valid_email($user)) { // Email given $email = $user; } elseif (is_integer($user)) { // Get users email $query = $this->CI->user_model->fetch('Users', 'email', NULL, array('id' => $user)); $user = $query->row(); $email = $user->email; } else { // Error return FALSE; } // Build email $subject = "[" . $this->CI->preference->item('site_name') . "] " . $subject; $message = $this->CI->parser->parse($view, $data, TRUE); // Setup Email settings $this->_initialize_email(); // Send email $this->CI->email->from($this->CI->preference->item('automated_from_email'), $this->CI->preference->item('automated_from_name')); $this->CI->email->to($email); $this->CI->email->subject($subject); $this->CI->email->message($message); if (!$this->CI->email->send()) { return FALSE; } return TRUE; }
/** * delete the eventIndex * * @param integer|Tx_CzSimpleCal_Domain_Model_Event $event */ public function delete($event) { if (is_integer($event)) { $event = $this->fetchEventObject($event); } $this->doDelete($event); }
public function get_size_info($size_name = 'thumbnail') { global $_wp_additional_image_sizes; if (is_integer($size_name)) { return; } if (is_array($size_name)) { return; } if (isset($_wp_additional_image_sizes[$size_name]['width'])) { $width = intval($_wp_additional_image_sizes[$size_name]['width']); } else { $width = get_option($size_name . '_size_w'); } if (isset($_wp_additional_image_sizes[$size_name]['height'])) { $height = intval($_wp_additional_image_sizes[$size_name]['height']); } else { $height = get_option($size_name . '_size_h'); } if (isset($_wp_additional_image_sizes[$size_name]['crop'])) { $crop = intval($_wp_additional_image_sizes[$size_name]['crop']); } else { $crop = get_option($size_name . '_crop') ? true : false; } return array('width' => $width, 'height' => $height, 'crop' => $crop); }
/** * @verbatim * Helper method that installs filter groups based on * the given XML node which represents a <filterGroups> * element. * @endverbatim * @param $filterGroupsNode XMLNode */ function installFilterGroups($filterGroupsNode) { // Install filter groups. $filterGroupDao = DAORegistry::getDAO('FilterGroupDAO'); /* @var $filterGroupDao FilterGroupDAO */ import('lib.pkp.classes.filter.FilterGroup'); foreach ($filterGroupsNode->getChildren() as $filterGroupNode) { /* @var $filterGroupNode XMLNode */ $filterGroupSymbolic = $filterGroupNode->getAttribute('symbolic'); // Make sure that the filter group has not been // installed before to guarantee idempotence. $existingFilterGroup =& $filterGroupDao->getObjectBySymbolic($filterGroupSymbolic); if (!is_null($existingFilterGroup)) { continue; } // Instantiate and configure the filter group. $filterGroup = new FilterGroup(); $filterGroup->setSymbolic($filterGroupSymbolic); $filterGroup->setDisplayName($filterGroupNode->getAttribute('displayName')); $filterGroup->setDescription($filterGroupNode->getAttribute('description')); $filterGroup->setInputType($filterGroupNode->getAttribute('inputType')); $filterGroup->setOutputType($filterGroupNode->getAttribute('outputType')); // Install the filter group. $installedGroupId = $filterGroupDao->insertObject($filterGroup); assert(is_integer($installedGroupId)); unset($filterGroup); } }
function LeerRegistro() { global $llamada, $valortag, $maxmfn, $arrHttp, $Bases, $xWxis, $Wxis, $Mfn, $db_path, $wxisUrl; // en la variable $arrHttp vienen los parámetros que se le van a pasar al script .xis // el índice IsisScript contiene el nombre del script .xis que va a ser invocado // la variable $llave permite retornar alguna marca que esté en el formato de salida // identificada entre $$LLAVE= .....$$ $llave_pft = ""; $IsisScript = $xWxis . "login.xis"; $query = "&base=acces&cipar={$db_path}" . "par/acces.par" . "&login="******"login"] . "&password="******"password"]; include "../common/wxis_llamar.php"; $ic = -1; $tag = ""; foreach ($contenido as $linea) { if ($ic == -1) { $ic = 1; $pos = strpos($linea, '##LLAVE='); if (is_integer($pos)) { $llave_pft = substr($linea, $pos + 8); $pos = strpos($llave_pft, '##'); $llave_pft = substr($llave_pft, 0, $pos); } } else { $linea = trim($linea); $pos = strpos($linea, " "); if (is_integer($pos)) { $tag = trim(substr($linea, 0, $pos)); } } } return $llave_pft; }
public function __construct($size = 64) { if (!is_integer($size)) { throw new InvalidParameterException('The "size" parameter of TextField have to be a number, current value: ' . $size); } $this->size = $size; }
/** * Sets the total row count, either directly or through a supplied query * * @param Doctrine_Query|integer $totalRowCount Total row count integer * or query * @return Zend_Paginator_Adapter_Doctrine $this * @throws Zend_Paginator_Exception */ public function setRowCount($rowCount) { if ($rowCount instanceof Doctrine_Query) { $sql = $rowCount->getSql(); if (false === strpos($sql, self::ROW_COUNT_COLUMN)) { /** * @see Zend_Paginator_Exception */ require_once 'Zend/Paginator/Exception.php'; throw new Zend_Paginator_Exception('Row count column not found'); } $result = $rowCount->fetchOne()->toArray(); $this->_rowCount = count($result) > 0 ? $result[self::ROW_COUNT_COLUMN] : 0; } else { if (is_integer($rowCount)) { $this->_rowCount = $rowCount; } else { /** * @see Zend_Paginator_Exception */ require_once 'Zend/Paginator/Exception.php'; throw new Zend_Paginator_Exception('Invalid row count'); } } return $this; }
/** * @param int $percent * @throws InvalidArgumentException */ public function setAlcoholContent($percent) { if (!is_integer($percent) || $percent < 0 || $percent > 100) { throw new InvalidArgumentException("Alcohol content needs to be valid integer lower than 100 an greater than 0."); } $this->alcoholContent = $percent; }
/** * Prepares and validates the sql parameters and sets the according class fields * * @return void * @throws Exception */ protected function _prepareSqlParams() { $entityTypeId = $this->getParam1(); if (empty($entityTypeId)) { throw new Exception('Param 1 must be an entity type code or entity type id'); } if (!is_integer($entityTypeId)) { $entityTypeId = $this->_getEntityTypeFromCode($entityTypeId); } $this->_entityTypeId = $entityTypeId; $storeId = $this->getParam2(); if (empty($storeId)) { throw new Exception('Param 2 must contain a store id or store code'); } if (!is_numeric($storeId)) { $storeId = $this->_getStoreIdFromCode($storeId); } $this->_storeId = $storeId; $incrementPrefix = $this->getValue(); if (empty($incrementPrefix)) { throw new Exception('Param 3 must be an increment prefix (integer)'); } if (!is_numeric($incrementPrefix)) { throw new Exception('Param 3 must be an integer'); } $this->_incrementPrefix = $this->_storeId . $incrementPrefix; $this->_incrementLastId = $this->_incrementPrefix . '00000000'; }
public function getCarouselItems($identifier = null, $withProducts = false, $withInactive = false, $withSchedule = false, $withLimit = false) { if (!$identifier) { $identifier = $this->getGroupIdentifier(); } $group = Mage::getModel('dhcarousel/group')->load($identifier, 'identifier'); $collection = Mage::getModel('dhcarousel/item')->getCollection()->addFieldToFilter('group_id', $group->getId()); if (!$withInactive) { $collection->addFieldToFilter('active', 1); } //passed by reference, so it affects the collection $collection->getSelect()->order('item_order', 'ASC'); if ($withProducts) { $this->addProductsToCollection($collection); } if ($withSchedule) { $todayStartOfDayDate = Mage::app()->getLocale()->date()->setTime('00:00:00')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); $todayEndOfDayDate = Mage::app()->getLocale()->date()->setTime('23:59:59')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); $collection->addFieldToFilter('from_date', array('or' => array(0 => array('date' => true, 'to' => $todayEndOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addFieldToFilter('to_date', array('or' => array(0 => array('date' => true, 'from' => $todayStartOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left'); } if ($withLimit && is_integer($withLimit)) { $collection->getSelect()->limit($withLimit); } return $collection; }
public static function serializeValue($value) { if ($value === null) { return 'null'; } elseif ($value === false) { return 'false'; } elseif ($value === true) { return 'true'; } elseif (is_float($value) && (int) $value == $value) { return $value . '.0'; } elseif (is_object($value) || gettype($value) == 'object') { return 'Object ' . get_class($value); } elseif (is_resource($value)) { return 'Resource ' . get_resource_type($value); } elseif (is_array($value)) { return 'Array of length ' . count($value); } elseif (is_integer($value)) { return (int) $value; } else { $value = (string) $value; if (function_exists('mb_convert_encoding')) { $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); } return $value; } }
/** * @param int $milliliters * @throws InvalidArgumentException */ public function __construct($milliliters) { if (!is_integer($milliliters) || $milliliters < 0) { throw new InvalidArgumentException("Liquid capacity need to be a valid integer value"); } $this->milliliters = $milliliters; }
/** * Try to figure out what type our data has. */ function calculateType() { if ($this->data === true || $this->data === false) { return 'boolean'; } if (is_integer($this->data)) { return 'int'; } if (is_double($this->data)) { return 'double'; } // Deal with XMLRPC object types base64 and date if (is_object($this->data) && $this->data instanceof XMLRPC_Date) { return 'date'; } if (is_object($this->data) && $this->data instanceof XMLRPC_Base64) { return 'base64'; } // If it is a normal PHP object convert it in to a struct if (is_object($this->data)) { $this->data = get_object_vars($this->data); return 'struct'; } if (!is_array($this->data)) { return 'string'; } /* We have an array - is it an array or a struct ? */ if ($this->isStruct($this->data)) { return 'struct'; } else { return 'array'; } }
function schema() { $this->column('id')->integer()->primary()->autoIncrement(); $this->column('name')->typeConstraint()->required()->varchar(128); $this->column('description')->varchar(128); $this->column('category_id')->integer(); $this->column('address')->varchar(64)->validator(function ($val, $args, $record) { if (preg_match('/f**k/', $val)) { return array(false, "Please don't"); } return array(true, "Good"); })->filter(function ($val, $args, $record) { return str_replace('John', 'XXXX', $val); })->default(function () { return 'Default Address'; })->varchar(256); $this->column('country')->varchar(12)->required()->index()->validValues(array('Taiwan', 'Taipei', 'Tokyo')); $this->column('type')->varchar(24)->validValues(function () { return array('Type Name A' => 'type-a', 'Type Name B' => 'type-b', 'Type Name C' => 'type-c'); }); $this->column('confirmed')->boolean(); $this->column('date')->date()->isa('DateTime')->deflator(function ($val) { if ($val instanceof \DateTime) { return $val->format('Y-m-d'); } elseif (is_integer($val)) { return strftime('%Y-%m-%d', $val); } return $val; })->inflator(function ($val) { return new \DateTime($val); }); $this->seeds('TestSeed'); }
/** * @covers WindowsAzure\Common\Internal\Filters\ExponentialRetryPolicy::calculateBackoff * @depends test__construct */ public function testCalculateBackoff($retryPolicy) { // Test $actual = $retryPolicy->calculateBackoff(2, null); // Assert $this->assertTrue(is_integer($actual)); }