ArrayObject PHP Class Code Examples

This page contains top rated real world PHP examples of class ArrayObject extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: TSet.php Project: yukar-php/linq
0
 /**
  * 要素の型に対して既定の等値比較子を使用して要素を比較することで、2 つのシーケンスが等しいかどうかを判断します。
  *
  * @param \ArrayObject $first  $second と比較するシーケンス
  * @param \ArrayObject $second 最初のシーケンスと比較するシーケンス
  *
  * @return bool 2 つのソースシーケンスが同じ長さで、それらに対応する要素が等しい場合は true。
  * それ以外の場合は false。
  */
 public function sequenceEqualOf(\ArrayObject $first, \ArrayObject $second) : bool
 {
     if ($first->count() != $second->count()) {
         return false;
     }
     return $this->exceptOf($first, $second)->count() === 0;
 }
Example #2
Show file File: Result.php Project: tin-cat/redis-info
0
 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;
 }
Example #3
Show file File: DiscountPlugin.php Project: b-medias/bZF2
0
 public function getDiscountBy($key)
 {
     $return = new ArrayObject();
     $array = new ArrayObject(array($key => $this->getConnecteur($key)));
     $connecteurs = $this->getConnecteur($key);
     if (is_array($connecteurs)) {
         foreach ($connecteurs as $connecteur) {
             if ($connecteur->discountDiscounts !== NULL) {
                 $discounts = $connecteur->discountDiscounts;
                 foreach ($discounts as $discount) {
                     if (!$return->offsetExists($discount->offsetGet('level'))) {
                         $return->offsetSet($discount->offsetGet('level'), new ArrayObject());
                     }
                     $discount->offsetSet('table', $key);
                     $return->offsetGet($discount->offsetGet('level'))->offsetSet(NULL, $discount);
                     break;
                 }
             }
         }
     } else {
         if ($connecteurs != NULL && $connecteurs->discountDiscounts !== NULL) {
             $discounts = $connecteurs->discountDiscounts;
             foreach ($discounts as $discount) {
                 if (!$return->offsetExists($discount->offsetGet('level'))) {
                     $return->offsetSet($discount->offsetGet('level'), new ArrayObject());
                 }
                 $discount->offsetSet('table', $key);
                 $return->offsetGet($discount->offsetGet('level'))->offsetSet(NULL, $discount);
                 break;
             }
         }
     }
     return $this->calcul($return);
 }
Example #4
Show file File: Restrictable.php Project: helpfulrobot/silverstripe-restrictedobjects
0
 /**
  * Allow users to specify an array of field level permission requirements on a content
  * object that will be checked when editing items. 
  * 
  * This should return an array (
  * 		'FieldName'		=> 'RequiredPermission',
  * )
  * 
  * Typically this is called directly in the extension so that OwnerID is always specified. 
  * 
  */
 public function fieldPermissions()
 {
     // so we can pass around by ref and not worry about end users NOT
     // using &$fields in their code...
     $fieldPerms = new ArrayObject();
     if (method_exists($this->owner, 'fieldPermissions')) {
         $fieldPerms = $this->owner->fieldPermissions();
         if (!is_array($fieldPerms)) {
             // force it to be an array
             $fieldPerms = new ArrayObject();
         }
     }
     $fieldPerms['OwnerID'] = 'TakeOwnership';
     $this->owner->extend('updateFieldPermissions', $fieldPerms);
     return $fieldPerms;
 }
Example #5
Show file File: Underscore.php Project: boliviasoftware/micro-system-maker
0
 /**
  * Calls the method named by methodName on each value in the list. Any extra arguments passed to invoke will be
  * forwarded on to the method invocation. If your list items are arrays (instead of objects) methods from
  * ArrayObject can be used (like asort). If the wanted method is not found on the current item during iteration,
  * the item will be left untouched.
  *
  * @category Collection Functions
  *
  * @param traversable $list the list of items to invoke method/function onto
  * @param callable,string $methodName the name of the method to invoke or a closure
  * @param array $arguments the method's arguments
  *
  * @return array
  */
 public static function invoke($list, $methodName, $arguments = array())
 {
     if (func_num_args() > 2 && !is_array($arguments)) {
         $arguments = array_slice(func_get_args(), 2);
     }
     return static::map($list, function ($item) use($methodName, $arguments) {
         if (is_scalar($item) || is_resource($item)) {
             return $item;
         }
         if ($cast_down = static::isArray($item, true)) {
             $item = new \ArrayObject($item);
         }
         if (static::isString($methodName, true) && method_exists($item, $methodName)) {
             $methodName = [$item, $methodName];
         } elseif ($methodName instanceof \Closure) {
             $methodName = $methodName->bindTo($item);
         } else {
             return $item;
         }
         call_user_func_array($methodName, $arguments);
         if ($cast_down) {
             $item = $item->getArrayCopy();
         }
         return $item;
     });
 }
Example #6
Show file File: Client.php Project: fredcido/simuweb
0
 /**
  *
  * @param Zend_Db_Table_Rowset $rows
  * @return array
  */
 public function visitPurpose($rows)
 {
     $purposes = array();
     foreach ($rows as $row) {
         if (!array_key_exists($row['purpose'], $purposes)) {
             $purposes[$row['purpose']] = array();
         }
         $gender = trim($row['gender']);
         if (!array_key_exists($gender, $purposes[$row['purpose']])) {
             $purposes[$row['purpose']][$gender] = 0;
         }
         $purposes[$row['purpose']][$gender]++;
     }
     ksort($purposes);
     $data = new ArrayObject(array('rows' => array(), 'total_man' => 0, 'total_man_porcent' => 0, 'total_woman' => 0, 'total_woman_porcent' => 0, 'total' => 0, 'graph' => array(), 'filters' => $this->_data));
     foreach ($purposes as $key => $row) {
         $row['man'] = empty($row['MANE']) ? 0 : (int) $row['MANE'];
         $row['woman'] = empty($row['FETO']) ? 0 : (int) $row['FETO'];
         $total = $row['man'] + $row['woman'];
         $data['rows'][] = array('purpose' => $key, 'total_man' => $row['man'], 'total_woman' => $row['woman'], 'total' => $total);
         $data['total'] += $total;
         $data['total_man'] += $row['man'];
         $data['total_woman'] += $row['woman'];
     }
     if (!empty($data['total'])) {
         $data['total_man_porcent'] = round(100 * $data['total_man'] / $data['total'], 2);
         $data['total_woman_porcent'] = round(100 * $data['total_woman'] / $data['total'], 2);
     }
     return $data;
 }
Example #7
Show file File: leadtracapi.php Project: jordone/diyonline
0
 public function CreateOrUpdateClient($campaignId, $properties, $fileNumber = null)
 {
     if (isset($this->DebugPage)) {
         $this->Debug_Log_Updated_Fields(array_keys($properties));
     }
     $soap_url = $this->GetClientWSDL();
     $parms = array();
     $parms[] = new SoapVar($this->userName, XSD_STRING, null, null, 'ns1:userName');
     $parms[] = new SoapVar($this->password, XSD_STRING, null, null, 'ns1:password');
     $parms[] = new SoapVar($campaignId, XSD_STRING, null, null, 'ns1:campaignId');
     // clientProperties
     $clientProperties = new ArrayObject();
     $propertyList = new ArrayObject();
     if (isset($fileNumber) && $fileNumber) {
         $properties['LeadNumber'] = $fileNumber;
     }
     // Encryption Storage System
     $i = 0;
     foreach ($properties as $propertyName => $propertyValue) {
         @($clientProperties[$i]->{'ns1:Name'} = $propertyName);
         @($clientProperties[$i]->{'ns1:Value'} = $propertyValue);
         $propertyList->append(new SoapVar($clientProperties[$i], SOAP_ENC_OBJECT, NULL, NULL, 'ns1:ClientProperty'));
         $i++;
     }
     //			array('FirstName', 'LastName', 'EmailAddress', 'HomeNumber');
     $parms[] = new SoapVar($propertyList, SOAP_ENC_OBJECT, NULL, NULL, 'ns1:propertyList');
     $soap = new SoapClient($soap_url, $this->GetSoapOptions());
     try {
         $call = $soap->CreateOrUpdateClient(new SoapVar($parms, SOAP_ENC_OBJECT));
         //if this was success! return it.
         if (isset($call->CreateOrUpdateClientResult)) {
             if (substr($call->CreateOrUpdateClientResult, 0, 7) == 'SUCCESS') {
                 if (substr($call->CreateOrUpdateClientResult, 8)) {
                     return substr($call->CreateOrUpdateClientResult, 8);
                 } else {
                     return true;
                 }
             } else {
                 $this->error = $call->CreateOrUpdateClientResult;
                 return false;
             }
         }
         return false;
     } catch (SoapFault $fault) {
         echo "<br/><br/><font color='red'>";
         print "Returned the following ERROR: " . $fault->faultcode . "-" . $fault->faultstring;
         echo "</font>";
         return false;
         //error
     }
 }
Example #8
Show file File: DeprecatedMappingExecutor.php Project: mrsinguyen/graphql-php
0
 /**
  * @param ExecutionContext $exeContext
  * @param ObjectType $objectType
  * @param $fieldASTs
  * @return \ArrayObject
  */
 private static function collectSubFields(ExecutionContext $exeContext, ObjectType $objectType, $fieldASTs)
 {
     $subFieldASTs = new \ArrayObject();
     $visitedFragmentNames = new \ArrayObject();
     for ($i = 0; $i < count($fieldASTs); $i++) {
         $selectionSet = $fieldASTs[$i]->selectionSet;
         if ($selectionSet) {
             $subFieldASTs = self::collectFields($exeContext, $objectType, $selectionSet, $subFieldASTs, $visitedFragmentNames);
         }
     }
     return $subFieldASTs;
 }
Example #9
Show file File: PagerfantaTest.php Project: 3lolo/lr_app
0
 private function assertResetCurrentPageResults($callback)
 {
     $this->setAdapterNbResultsAny(100);
     $this->pagerfanta->setMaxPerPage(10);
     $currentPageResults0 = new \ArrayObject();
     $currentPageResults1 = new \ArrayObject();
     $this->adapter->expects($this->at(0))->method('getSlice')->will($this->returnValue($currentPageResults0));
     $this->adapter->expects($this->at(1))->method('getSlice')->will($this->returnValue($currentPageResults1));
     $this->assertSame($currentPageResults0, $this->pagerfanta->getCurrentPageResults());
     $callback();
     $this->assertSame($currentPageResults1, $this->pagerfanta->getCurrentPageResults());
 }
Example #10
Show file File: IndexController.php Project: lstaszak/zf2_aleph_platnosci
0
 public function secendoptionuserajaxAction()
 {
     $oResponse = $this->getResponse();
     $bSuccess = false;
     if ($this->getRequest()->isPost()) {
         $sSecendOption = $this->params()->fromPost('second_opinion');
         $sColumnName = $this->params()->fromPost('column_name');
         $nId = $this->params()->fromPost('id') !== '' ? (int) $this->params()->fromPost('id') : null;
         if ($nId) {
             $oUserEntity = new UserEntity();
             switch ($sSecendOption) {
                 case 'enable_disable':
                     $oUser = $this->getUserTable()->getRow(array('id' => $nId));
                     if (isset($oUser->{$sColumnName})) {
                         if ($oUser->{$sColumnName} === 1) {
                             $oData = new \ArrayObject(array('id' => $nId, $sColumnName => 0));
                             $this->getUserTable()->changeActive($oUserEntity->setOptions($oData));
                             $bSuccess = true;
                         } else {
                             if ($oUser->{$sColumnName} === 0) {
                                 $oData = new \ArrayObject(array('id' => $nId, $sColumnName => 1));
                                 $this->getUserTable()->changeActive($oUserEntity->setOptions($oData));
                                 $bSuccess = true;
                             }
                         }
                     }
                     break;
             }
         }
     }
     $oResponse->setContent(\Zend\Json\Json::encode($bSuccess));
     return $oResponse;
 }
Example #11
Show file File: ParserWLM.php Project: munishsethi777/eliveui
0
 public static function parseSLMFromString($theData, $loggerDB)
 {
     $loggerDB->info("Now into parsing method");
     $COLS = new ArrayObject();
     $COLS[0] = "DATE";
     $COLS[1] = "TIME";
     $COLS[2] = "LEQ";
     $COLS[3] = "MIN";
     $COLS[4] = "MAX";
     $COLS[5] = "L10";
     $COLS[6] = "L50";
     $COLS[7] = "L90";
     $COLS[8] = "SEL";
     $COLS[9] = "CRC";
     //$myFile = "../files/data.slm";
     $lineVals = explode(',', $theData);
     $count = count($lineVals) - 1;
     $totRows = $count / 11;
     $arrayCount = 0;
     $SLMArray = new ArrayObject();
     //loop over each row of information in the SLM
     $varIndex = 0;
     for ($a = 0; $a <= $totRows; $a++) {
         $dated = null;
         if ($lineVals[$varIndex] != null && $lineVals[$varIndex + 1] != null) {
             $datedStr = $lineVals[$varIndex];
             $timed = $lineVals[++$varIndex];
             $crc = "";
             if ($a != 0) {
                 $crc = substr($datedStr, 0, 1);
                 $datedStr = substr($datedStr, 1, 8);
             }
             $dateWithoutSlashes = str_replace('/', '-', $datedStr);
             // dd-mm-yyyy
             $date_parts = array_reverse(explode("-", $dateWithoutSlashes));
             $dateReFormated = implode('-', $date_parts);
             $timestamp = strtotime($dateReFormated . " " . $timed);
             $dated = date('Y-m-d H:i:s', $timestamp);
             $SLM = new SLM();
             $SLM->setDated($dated);
             $SLM->setLEQ($lineVals[++$varIndex]);
             $SLM->setMIN($lineVals[++$varIndex]);
             $SLM->setMAX($lineVals[++$varIndex]);
             $SLM->setL10($lineVals[++$varIndex]);
             $SLM->setL50($lineVals[++$varIndex]);
             $SLM->setL90($lineVals[++$varIndex]);
             $SLM->setSEL($lineVals[++$varIndex]);
             $SLM->setCRC($crc);
             $SLMDS = SLMDataStore::getInstance();
             $res = $SLMDS->SaveSML($SLM);
             $varIndex = $varIndex + 3;
             //padding variable and another increased
         }
     }
     //for loop
     $loggerDB->info("Parser came out of loop now");
 }
Example #12
Show file File: ValidTest.php Project: artbypravesh/morningpages
0
 /**
  * Returns test data for test_not_empty()
  *
  * @return array
  */
 public function provider_not_empty()
 {
     // Create a blank arrayObject
     $ao = new ArrayObject();
     // arrayObject with value
     $ao1 = new ArrayObject();
     $ao1['test'] = 'value';
     return array(array(array(), FALSE), array(NULL, FALSE), array('', FALSE), array($ao, FALSE), array($ao1, TRUE), array(array(NULL), TRUE), array(0, TRUE), array('0', TRUE), array('Something', TRUE));
 }
Example #13
Show file File: Parser.php Project: rafasashi/ApiGen
0
 private function loadToParserResult(ArrayObject $classes, ArrayObject $constants, ArrayObject $functions, ArrayObject $internalClasses, ArrayObject $tokenizedClasses)
 {
     $this->parserStorage->setClasses($classes);
     $this->parserStorage->setConstants($constants);
     $this->parserStorage->setFunctions($functions);
     $this->parserStorage->setInternalClasses($internalClasses);
     $this->parserStorage->setTokenizedClasses($tokenizedClasses);
 }
Example #14
Show file File: ZendLuceneSearch.php Project: SimonBaeumer/humhub
0
 public function find($keyword, array $options)
 {
     $options = $this->setDefaultFindOptions($options);
     $index = $this->getIndex();
     $keyword = str_replace(array('*', '?', '_', '$'), ' ', mb_strtolower($keyword, 'utf-8'));
     if (!isset($options['sortField']) || $options['sortField'] == "") {
         $hits = new \ArrayObject($index->find($this->buildQuery($keyword, $options)));
     } else {
         $hits = new \ArrayObject($index->find($this->buildQuery($keyword, $options), $options['sortField']));
     }
     $resultSet = new SearchResultSet();
     $resultSet->total = count($hits);
     $resultSet->pageSize = $options['pageSize'];
     $resultSet->page = $options['page'];
     $hits = new \LimitIterator($hits->getIterator(), ($options['page'] - 1) * $options['pageSize'], $options['pageSize']);
     foreach ($hits as $hit) {
         $document = $hit->getDocument();
         $result = new SearchResult();
         $result->model = $document->getField('model')->getUtf8Value();
         $result->pk = $document->getField('pk')->getUtf8Value();
         $result->type = $document->getField('type')->getUtf8Value();
         $resultSet->results[] = $result;
     }
     return $resultSet;
 }
Example #15
Show file File: CronkGridTemplateWorker.class.php Project: philippjenni/icinga-web
0
 /**
  * TODO: API CALL CHANGE
  * @param IcingaApiResult $result
  * @return ArrayObject
  */
 protected function rewriteResultRow($result)
 {
     $row = new ArrayObject($result->getRow());
     $out = new ArrayObject();
     foreach ($this->getTemplate()->getFields() as $key => $field) {
         $meta = $this->getTemplate()->getFieldByName($key, 'display');
         $data = $this->getFieldData($row, $key);
         $out[$key] = $data;
     }
     // Adding additional fields
     $out = array_merge((array) $out, (array) $this->addAdditionalFieldResults($result));
     unset($row);
     $raw = (array) $out;
     foreach ($out as $key => $val) {
         $meta = $this->getTemplate()->getFieldByName($key, 'display');
         if (($param = $meta->getParameter('userFunc')) || ($param = $meta->getParameter('phpFunc'))) {
             if (!isset($param['model'])) {
                 continue;
             }
             if ($param['model'] && $param['method']) {
                 if (!array_key_exists('arguments', $param) && !isset($param['arguments'])) {
                     $param['arguments'] = array();
                 } elseif (!is_array($param['arguments'])) {
                     $param['arguments'] = array();
                 }
                 $out[$key] = $this->rewritePerClassMethod($param['model'], $param['method'], $val, $param['arguments'], (array) $raw);
             }
         }
     }
     return $out;
 }
Example #16
Show file File: VariablesInAllowedPosition.php Project: ntf/graphql-php
0
 public function __invoke(ValidationContext $context)
 {
     $varDefMap = new \ArrayObject();
     $visitedFragmentNames = new \ArrayObject();
     return ['visitSpreadFragments' => true, Node::OPERATION_DEFINITION => function () use(&$varDefMap, &$visitedFragmentNames) {
         $varDefMap = new \ArrayObject();
         $visitedFragmentNames = new \ArrayObject();
     }, Node::VARIABLE_DEFINITION => function (VariableDefinition $varDefAST) use($varDefMap) {
         $varDefMap[$varDefAST->variable->name->value] = $varDefAST;
     }, Node::FRAGMENT_SPREAD => function (FragmentSpread $spreadAST) use($visitedFragmentNames) {
         // Only visit fragments of a particular name once per operation
         if (!empty($visitedFragmentNames[$spreadAST->name->value])) {
             return Visitor::skipNode();
         }
         $visitedFragmentNames[$spreadAST->name->value] = true;
     }, Node::VARIABLE => function (Variable $variableAST) use($context, $varDefMap) {
         $varName = $variableAST->name->value;
         $varDef = isset($varDefMap[$varName]) ? $varDefMap[$varName] : null;
         $varType = $varDef ? TypeInfo::typeFromAST($context->getSchema(), $varDef->type) : null;
         $inputType = $context->getInputType();
         if ($varType && $inputType && !$this->varTypeAllowedForType($this->effectiveType($varType, $varDef), $inputType)) {
             return new Error(Messages::badVarPosMessage($varName, $varType, $inputType), [$variableAST]);
         }
     }];
 }
Example #17
Show file File: Filesystem.php Project: yangwu/EvaThumber
0
 /**
  * @param mixed $files
  *
  * @return \Traversable
  */
 private function toIterator($files)
 {
     if (!$files instanceof \Traversable) {
         $files = new \ArrayObject(is_array($files) ? $files : array($files));
     }
     return $files;
 }