/** * Obtem um param enviado via Request Http * @param int|string $index * @return mixed|boolean */ public function getParam($index) { if ($this->params->offsetExists($index)) { return $this->params->offsetGet($index); } return false; }
/** * Valida o código de barras. * @param mixed $value * @return boolean */ public function validate($input) { $input = new StringHelper($input); $digitoCean = 0; $indiceInicial = 0; $digitoCalculo = 0; $digitoCalculado = 0; $tamCean = $input->length; $ceanSemDigito = new StringHelper(); if (!in_array($tamCean, array(8, 12, 13, 14, 18))) { return false; } $digitoCean = (int) $input->right(1, 1)->getValue(); $ceanSemDigito->setValue($input->left(0, $input->length - 1)->getValue()); $indiceInicial = $this->p->count() - $ceanSemDigito->length; for ($i = 0; $i < $ceanSemDigito->length; $i++) { $digitoCalculo += (int) $ceanSemDigito->substring($i, 1)->getValue() * $this->p->offsetGet($indiceInicial++); } if ($digitoCalculo % 10 == 0) { $digitoCalculado = 0; } else { $divTemp = (int) ceil($digitoCalculo / 10.0) * 10; $digitoCalculado = $divTemp - $digitoCalculo; } if ($digitoCalculado === $digitoCean) { return true; } return false; }
/** * Obtem o caminho de um diretorio * @param string $index * @return boolean */ public function getDirectory($index) { if ($this->paths->offsetExists($index)) { return $this->paths->offsetGet($index); } return false; }
/** * Get a service. * * @param string $name The name of the service * * @return \Subbly\Api\Service\Service * * @throws \Subbly\Api\Exception If the service name does not exists * * @api */ public function service($name) { if (!$this->services->offsetExists($name)) { throw new Exception(sprintf(Exception::SERVICE_NOT_EXISTS, $name)); } return $this->services->offsetGet($name); }
/** * Get component data * * @param string $name * @return array * @throws LocalizedException */ public function getComponentData($name) { if (!$this->componentData->offsetExists($name)) { throw new LocalizedException(new Phrase('The requested component ("' . $name . '") is not found. ' . 'Before using, you must add the implementation.')); } return (array) $this->componentData->offsetGet($name); }
/** * @return mixed * @param string $name * @param mixed $defaultValue */ public function getArgument($name, $defaultValue = null) { if ($this->arguments->offsetExists($name)) { return $this->arguments->offsetGet($name); } return $defaultValue; }
public function getParam($name) { if (!$this->storage->offsetExists($name)) { return null; } return $this->storage->offsetGet($name); }
/** * Returns required option value * * @param string $optionName * @return mixed */ public function getOption($optionName) { if ($this->_options instanceof ArrayObject && $this->_options->offsetExists($optionName)) { return $this->_options->offsetGet($optionName); } return NULL; }
/** * Proccess queue * * @param int $maxExecutionTime Maximum execution time available * * @return boolean If all requested items could be processed */ public function processQueue($maxExecutionTime = INF) { try { /* @var $shipment Dhl_Intraship_Model_Mysql4_Shipment_Collection */ $collection = Mage::getModel('intraship/shipment')->getCollection()->joinOrderTable(); // Add filter status codes to where clause. $collection->addFieldToFilter('main_table.status', array('in' => array(Dhl_Intraship_Model_Shipment::STATUS_NEW_QUEUED, Dhl_Intraship_Model_Shipment::STATUS_NEW_RETRY, Dhl_Intraship_Model_Shipment::STATUS_CANCEL_QUEUED, Dhl_Intraship_Model_Shipment::STATUS_CANCEL_RETRY))); // Create shipment for each queue. if (0 < count($collection)) { $startTime = time(); $shipmentOffset = 0; /* @var $row Dhl_Intraship_Model_Shipment */ foreach ($collection as $shipment) { ++$shipmentOffset; //Skip shipment if current status has changed to avoid double shipment transmission if (Mage::getModel('intraship/shipment')->load($shipment->getId())->getStatus() != $shipment->getStatus()) { continue; } try { $fallback = new ArrayObject(array()); if (!$shipment instanceof Dhl_Intraship_Model_Shipment) { continue; } switch ($shipment->getStatus()) { case Dhl_Intraship_Model_Shipment::STATUS_NEW_QUEUED: case Dhl_Intraship_Model_Shipment::STATUS_NEW_RETRY: $fallback->offsetSet('type', 'create'); $fallback->offsetSet('status', Dhl_Intraship_Model_Shipment::STATUS_NEW_FAILED); $this->_create($shipment); break; case Dhl_Intraship_Model_Shipment::STATUS_CANCEL_QUEUED: case Dhl_Intraship_Model_Shipment::STATUS_CANCEL_RETRY: $fallback->offsetSet('type', 'cancel'); $fallback->offsetSet('status', Dhl_Intraship_Model_Shipment::STATUS_CANCELED_FAILED); $this->_cancel($shipment); break; } } catch (Exception $e) { Mage::logException($e); $this->logMessage($e->getMessage()); $shipment->setStatus($fallback->offsetGet('status'))->setClientStatusCode(1000)->setClientStatusMessage($e->getMessage())->addComment($e->getMessage(), $fallback->offsetGet('status'), $fallback->offsetGet('type')); } if ($shipment->getShipment()->getId() && $shipment->getShipment()->getOrder()->getId()) { // Save comments. $shipment->saveComments(); // Save modified shipment. $shipment->save(); } // Stop processing 10s before we run out of time if ($shipmentOffset < $collection->count() && $maxExecutionTime - 10 < time() - $startTime) { return false; } } } } catch (Exception $e) { Mage::logException($e); throw new Dhl_Intraship_Model_Soap_Client_Response_Exception($e->getMessage(), $e->getCode()); } return true; }
/** * Check the object cache see if the data has already been retrieved * * This cache is only persisted throughout a request * * @param KCommandContext $context * * @return void */ protected function _beforeRepositoryFetch(KCommandContext $context) { if ($this->_enable) { $key = $this->_getCacheKey($context->query); if (self::$_cache->offsetExists($key)) { $context->data = self::$_cache->offsetGet($key); return false; } } }
/** * returns field descriptor * * @throws \VisioCrudModeler\Exception\FieldNotFound * @return DbFieldDescriptor */ public function getFieldDescriptor($fieldName) { if (!array_key_exists($fieldName, $this->definition['fields'])) { throw new FieldNotFound("field '" . $fieldName . "' not found in '" . $this->getName() . "'"); } if (!$this->fieldDescriptors->offsetExists($fieldName)) { $this->fieldDescriptors->offsetSet($fieldName, new WebFieldDescriptor($this, $this->definition['fields'][$fieldName])); } return $this->fieldDescriptors->offsetGet($fieldName); }
/** * @param string $index * @param null|string $defaultValue * @param bool $filtered If you trust foreign input introduced to your PHP code - set to FALSE! * * @return string */ public function get($index, $defaultValue = null, $filtered = true) { if ($this->data->offsetExists($index)) { if ($filtered === true) { // pretty high-level filtering here... return self::filter($this->data->offsetGet($index)); } return $this->data->offsetGet($index); } return $defaultValue; }
/** * @param $name * @param bool|false $throw_exception * @return PluginBootstrap|null * @throws PluginManagerException */ public function get($name, $throw_exception = false) { if (!$this->arrayObject->offsetExists($name)) { $this->load($name, $throw_exception); } if ($this->arrayObject->offsetExists($name)) { return $this->arrayObject->offsetGet($name); } else { return null; } }
/** * @return bool */ public function isClosed() { if ($this->points->count() < 3) { return false; } $firstPoint = $this->points->offsetGet(0); $lastPoint = $this->points->offsetGet($this->points->count() - 1); if ($firstPoint->getX() == $lastPoint->getX() && $firstPoint->getY() == $lastPoint->getY()) { return true; } return false; }
public function setDatabases() { $databases = new ArrayObject(); foreach ($this->getResponse() as $value) { $line = new ArrayObject(explode(':', $value, 2)); if (strpos($line->offsetGet(0), self::DB_KEY) !== FALSE) { preg_match(self::DB_PATTERN, $line->offsetGet(1), $matches); $databases->offsetSet($line->offsetGet(0), new ArrayObject($matches)); } } $this->databases = $databases; }
/** * Get Map to business or dao * @param string $index * @param array $map */ public function getMapTo($index, $to) { if ($this->maps->offsetExists($index)) { $map = $this->maps->offsetGet($index); if (in_array($to, array('db', 'object'))) { return $map[$to]; } return FALSE; } else { return FALSE; } }
/** * Get an item from an array using "dot" notation. * * @param string|integer $index The index or identifier. * @param mixed $default * * @return mixed|null */ public static function get($index, $default = null) { if (self::$battery->offsetExists($index)) { return self::$battery->offsetGet($index); } $array = self::$battery->getArrayCopy(); foreach ((array) explode('.', $index) as $segment) { if (!is_array($array) || !array_key_exists($segment, $array)) { return $default; } $array = $array[$segment]; } return $array; }
public function setPool() { $pool = new Pool(); foreach ($this->getConfiguration() as $key => $value) { $array = new ArrayObject($value); $server = new Server(); $server->setHost($array->offsetGet(self::SERVER_PROPERTY_HOST))->setPort($array->offsetGet(self::SERVER_PROPERTY_PORT))->setName($key); if ($array->offsetExists(self::SERVER_PROPERTY_AUTH)) { $server->setAuth($array->offsetGet(self::SERVER_PROPERTY_AUTH)); } $pool->attach($server); } $this->pool = $pool; }
/** * Return a synthetic table * * @param string $table_name table name * * @throws Exception\InvalidArgumentException if table name is not valid * * @return Table */ public function table($table_name) { if (!is_string($table_name)) { throw new Exception\InvalidArgumentException(__METHOD__ . ": Table name must be a string"); } if (!$this->localTableCache->offsetExists($table_name)) { $tables = $this->metadata()->getTables(); if (!in_array($table_name, $tables)) { throw new Exception\TableNotFoundException(__METHOD__ . ": Table {$table_name} is not found in database, if table exists please make sure cache is updated."); } $table = new Table($table_name, $this); $this->localTableCache->offsetSet($table_name, $table); } return $this->localTableCache->offsetGet($table_name); }
/** * Retrieves a writer from the collection. * * @param string $index the name of the writer to retrieve. * * @throws \InvalidArgumentException if the writer is not in the collection. * * @return WriterAbstract */ public function offsetGet($index) { if (!$this->offsetExists($index)) { throw new \InvalidArgumentException('Writer "' . $index . '" does not exist'); } return parent::offsetGet($index); }
/** * Return null if the offset doesn't exits. * * (non-PHPdoc) * * @see ArrayObject::offsetGet() */ public function offsetGet($key) { if ($this->offsetExists($key)) { return parent::offsetGet($key); } return; }
/** * Gibt das Element der Liste zurück wenn es existiert * @param mixed $index * @throws InvalidArgumentException */ public function offsetGet($index) { if (!parent::offsetExists($index)) { throw new Dragon_Application_Exception_System('missing record', array('index' => $index)); } return parent::offsetGet($index); }
/** * シーケンス内の指定されたインデックス位置にある要素を返します。 * * @param \ArrayObject $source 返される要素が含まれるシーケンス * @param int $index 取得する要素の 0 から始まるインデックス * * @return mixed シーケンス内の指定された位置にある要素 */ public function elementAtOf(\ArrayObject $source, int $index) { if ($index < 0 || $index >= $source->count()) { throw new \OutOfRangeException(); } return $source->offsetGet($index); }
public function offsetGet($name) { $resource = parent::offsetGet($name); $resource->__parent = $this; $resource->__name = $name; return $resource; }
/** * (PHP 5 >= 5.0.0)<br/> * Offset to retrieve * @link http://php.net/manual/en/arrayaccess.offsetget.php * @param int $index <p> * The offset to retrieve. * </p> * @throws \Exception * @return mixed Can return all value types. */ public function &offsetGet($index) { if (!$this->offsetExists($index)) { $this->offsetSet($index, $this->getDefault()); } return parent::offsetGet($index); }
/** * Return the given offset. * Throw an exception if the given offset does not exist. * * @throws \InvalidArgumentException */ public function offsetGet($offset) { if (!$this->offsetExists($offset)) { throw new \InvalidArgumentException(sprintf('Column "%s" does not exist, valid columns: "%s"', $offset, implode('", "', array_keys($this->getArrayCopy())))); } return parent::offsetGet($offset); }
public function offsetGet($offset) { if (!isset($this->data)) { $this->lazyInitialization(); } return $this->data->offsetGet($offset); }
/** * Method to retrieve an element from the collection. * @access public * @throws Exception * @return tx_crawler_domain_process */ public function offsetGet($index) { if (!parent::offsetExists($index)) { throw new Exception('Index "' . var_export($index, true) . '" for tx_crawler_domain_process are not available'); } return parent::offsetGet($index); }
/** * Offset get method * * @param string $name * @throws \InvalidArgumentException * @return mixed */ public function offsetGet($name) { if (!array_key_exists($name, $this->allowed)) { throw new \InvalidArgumentException("The property '" . $name . "' is not a valid property."); } return parent::offsetGet($name); }
/** * Finds a format by the given name or throws an exception if that index is not found. * * @param string $index * * @throws Exception\FormatNotFoundException if the given format index was not found. * * @return Format */ public function offsetGet($index) { if (!$this->offsetExists($index)) { throw new Exception\FormatNotFoundException('Format ' . $index . ' is not known'); } return parent::offsetGet($index); }