Exemplo n.º 1
0
 /**
  * Get parsed payments
  *
  * @return \ArrayObject Payments array
  */
 public function getPayments()
 {
     if ($this->_payments->count() == 0) {
         $this->_logger->info("No payments found, did you invoke Parser::parse() before this call?");
     }
     return $this->_payments;
 }
 public function count()
 {
     if (!isset($this->data)) {
         $this->lazyInitialization();
     }
     return $this->data->count();
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * @return \ArrayObject|DistributorItem[]
  */
 public function getAll()
 {
     if (!$this->items->count()) {
         if ($this->rawItems->count()) {
             foreach ($this->rawItems as $item) {
                 $this->items->append(new DistributorItem($item));
             }
         }
     }
     return $this->items;
 }
Exemplo n.º 5
0
 /**
  * @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;
 }
Exemplo n.º 6
0
 /**
  * Crea un fichero csv con todas las facturas en sistema extraidas
  * en el corte de la consulta.
  */
 public function createCVS()
 {
     $message = null;
     try {
         \helper\FileSystemHelper::createCVS('allInvoicesFromDatabase', $this->listDTO);
         $dir = __DIR__;
         $message = " Se ha creado el archivo  allInvoicesFromDatabase.csv  en {$dir}\n";
         echo "{$this->listDTO->count()}\n";
     } catch (\Exception $e) {
         error_log($e->getMessage(), 0);
         error_log($e->getTraceAsString(), 0);
         $message = " {$e->getMessage()}";
     }
     return $message;
 }
Exemplo n.º 7
0
 /**
  * Run TestCase.
  *
  * @param TestCase $testCase
  *
  * @return int Status code
  */
 public function run(TestCase $testCase)
 {
     $this->precondition($testCase);
     if ($this->tests->count() == 0) {
         $this->logger->notice('Tests not found in TestCase', ['pid' => getmypid()]);
         /** @var EventDispatcherInterface $dispatcher */
         $dispatcher = $this->container->get('dispatcher');
         $dispatcher->dispatch(EventStorage::EV_CASE_FILTERED);
         return 1;
     }
     $statusCode = 0;
     $testCaseEvent = new TestCaseEvent($this->reflectionClass->getName());
     $testCaseEvent->setAnnotations(self::getAnnotations($this->reflectionClass->getDocComment()));
     $this->controller->beforeCase($testCaseEvent);
     foreach ($this->tests as $test) {
         if ($test->getStatus() !== TestMeta::TEST_NEW && $test->getStatus() !== TestMeta::TEST_MARKED) {
             continue;
         }
         if ($this->testMethod($test)) {
             $statusCode = 1;
         }
     }
     $this->controller->afterCase($testCaseEvent);
     return $statusCode;
 }
Exemplo n.º 8
0
 /**
  * シーケンス内の指定されたインデックス位置にある要素を返します。
  *
  * @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);
 }
Exemplo n.º 9
0
 private function parseRawToList($raw)
 {
     $raw = trim($raw);
     if (!empty($raw)) {
         $list = new \ArrayObject();
         $token = explode(PHP_EOL, $raw);
         $a = 1;
         while ($a < count($token)) {
             next($token);
             $attr = new Attribute();
             if (!(current($token) == "!re") && !(current($token) == "!trap")) {
                 $split = explode("=", current($token));
                 $attr->setName($split[1]);
                 if (count($split) == 3) {
                     $attr->setValue($split[2]);
                 } else {
                     $attr->setValue(NULL);
                 }
                 $list->append($attr);
             }
             $a++;
         }
         if ($list->count() != 0) {
             $this->result->add($list);
         }
     }
 }
Exemplo n.º 10
0
 public function buildLastPage()
 {
     $page = null;
     if ($this->listPage->count() > 0) {
         $page = $this->listPage->offsetGet($this->listPage->count());
     }
     $this->lastPage = $page;
 }
Exemplo n.º 11
0
 public function getResultsFound()
 {
     if ($this->results->count() > 0) {
         $result = $this->results->getIterator();
         $responseJson = '[';
         while ($result->valid()) {
             $object = $this->buildObject($result->current());
             $responseJson .= $object->toJSON() . ',';
             $result->next();
         }
         $responseJson = substr($responseJson, 0, -1);
         $responseJson .= ']';
         return $responseJson;
     } else {
         return null;
     }
 }
Exemplo n.º 12
0
 public function getCurrentSitemapNode(Request $request)
 {
     $routeName = $request->get('_route');
     $routeParameters = $request->get('_route_params');
     //Agregar los parámetros http del requerimiento actual a la WebLocation.
     $routeParameters = array_merge($routeParameters, $request->query->all());
     $location = new RouteBasedLocation($routeName, $routeParameters);
     $it = new RouteSitemapNodeFilterIterator($this->getSitemap()->getIterator(), $location);
     $nodes = new \ArrayObject(iterator_to_array($it, false));
     if ($nodes->count() > 1) {
         throw new \Exception("Se encontró mas de un nodo en el sitemap que coincide con el requerimiento HTTP.");
     }
     if ($nodes->count() == 0) {
         throw new \Exception("No se encontró ningun nodo en el sitemap que coincida con el requerimiento actual.");
     } else {
         return $nodes[0];
     }
 }
Exemplo n.º 13
0
 /**
  * @dataProvider providerOfType
  */
 public function testOfType($source, $type, $expectedParam)
 {
     $expected = new \ArrayObject($expectedParam);
     $mock = $this->getMockForTrait('Yukar\\Linq\\Enumerable\\TInspection');
     $result = $mock->ofTypeOf(new \ArrayObject($source), $type);
     $this->assertInstanceOf('\\ArrayObject', $result);
     $this->assertCount($expected->count(), $result);
     $this->assertEquals($expected, $result);
 }
Exemplo n.º 14
0
 /**
  * @param \ArrayObject|\ArrayObject[] $logs
  * @param bool $amsterdamSuffix
  *
  * @return string
  */
 protected function drawHTML($logs, $amsterdamSuffix = false)
 {
     $displayLog = '';
     if ($logs && $logs->count()) {
         foreach ($logs as $log) {
             if ($log['action_id'] == Logger::ACTION_BLOB) {
                 $displayLog .= $this->blobBeautifier($log['value']);
             } else {
                 $displayLog .= $this->concatFieldsHTML($log, $amsterdamSuffix);
             }
         }
     }
     return $displayLog;
 }
Exemplo n.º 15
0
 /**
  * Retrieve modules directories
  * @return ArrayObject
  */
 public function getModulesDirectories()
 {
     if (self::$modulesDirectories->count() == 0) {
         foreach (scandir(self::$applicationDirectory) as $directory) {
             if ($directory == '..' || $directory == '.') {
                 continue;
             }
             if (is_dir(self::$applicationDirectory . DIRECTORY_SEPARATOR . $directory)) {
                 self::$modulesDirectories->append(realpath(self::$applicationDirectory . DIRECTORY_SEPARATOR . $directory));
             }
         }
     }
     return self::$modulesDirectories;
 }
 private function parserQueryStringIntoKeywords($query_string)
 {
     $arrayObject = new ArrayObject(explode(",", trim($query_string)));
     $result = new ArrayObject();
     if ($arrayObject->count() > 0) {
         foreach ($arrayObject as $value) {
             $array = explode(" ", $value);
             foreach ($array as $value2) {
                 $keyword = strtolower(trim($value2));
                 if ($this->isKeyword($keyword)) {
                     $result->append($value2);
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 17
0
 /**     
  * @param ArrayObject $listOfData
  * @return HashMap 
  */
 public function groupDataValues(ArrayObject $listOfData)
 {
     $mapGrouped = new HashMap();
     if ($listOfData->count() > 0) {
         $dataToGroup = $this->objectData($listOfData->offsetGet(0));
         $list = $listOfData->getIterator();
         $list2 = $listOfData->getIterator();
         $dataAux = null;
         $i = 0;
         while ($list->valid()) {
             $auxList = $this->getDataOfSameTypeAndPutIntoList($list2, $dataToGroup, $dataAux);
             $this->changePointers($list, $list2, $dataAux, $dataToGroup);
             $this->changeDataToGroup($list, $dataToGroup);
             $this->groupIntoMap($mapGrouped, $auxList, $i);
         }
     }
     return $mapGrouped;
 }
 public function authorizeSync($request, &$message)
 {
     if ($this->rules->count() === 0) {
         $message = 'No rules defined, no restrictions applied.';
         return 0;
     }
     // Exit on the first applicable result:
     foreach ($this->rules as $rule) {
         if ($rule instanceof PolicyRule && $rule->isApplicableTo($request)) {
             if ($rule->isAllow()) {
                 $message = $rule->getDescription();
                 return 0;
             } else {
                 $message = $rule->getDescription();
                 return $rule->getIdentifier();
             }
         }
     }
     $message = 'Denied by default';
     return 1;
 }
Exemplo n.º 19
0
 /**
  * HttpRequest class
  * Construct HTTP Request
  * @param String $queryString
  */
 private function __construct(string $queryString)
 {
     $this->requestGet = new \ArrayObject();
     $str_decodeUrl = str_replace("request=", "", urldecode($queryString));
     $str_decodeUrl = rtrim($str_decodeUrl, ' /');
     // yeap, with blank space
     $arr_moduleAction = explode('/', $str_decodeUrl);
     $int_totalModuleActions = count($arr_moduleAction);
     if (empty($str_decodeUrl)) {
         return;
     }
     if ($int_totalModuleActions <= 1) {
         $arr_moduleAction[] = 'index';
         // if action not set, try to open index
     }
     if ($int_totalModuleActions > 2) {
         // Populating GET Request Parameters
         for ($i = 2; $i < $int_totalModuleActions; $i += 2) {
             $this->requestGet->offsetSet($arr_moduleAction[$i], isset($arr_moduleAction[$i + 1]) ? new String($arr_moduleAction[$i + 1]) : new String(""));
         }
     }
     $this->parsePostParameters();
     $arr_moduleAction = new \ArrayObject($arr_moduleAction);
     $this->module = new String($arr_moduleAction->offsetGet(0));
     if ($arr_moduleAction->offsetExists(1)) {
         $this->action = new String($arr_moduleAction->offsetGet(1));
     }
     if ($arr_moduleAction->count() < 2) {
         return;
     }
     $this->request = new \ArrayObject(array_merge($this->requestGet->getArrayCopy(), $this->requestPost->getArrayCopy()));
 }
 public function prepareDays()
 {
     $JourFactory = new FlyweightJourFactory();
     $arrayTemp = $this->AffectationDone->getArrayCopy();
     /**		for ($i = count($arrayTemp)-2; $i >=0; $i--) {
     			for ($j = 0; $j <= $i; $j++) {
     				if($arrayTemp[$j+1]->Heure->getHoraireDebut() > $arrayTemp[$j]->Heure->getHoraireDebut()){
     					$t = $arrayTemp[$j+1];
     					$arrayTemp[$j+1] = $arrayTemp[$j];
     					$arrayTemp[$j] = $t;
     				}
     			}
     		}
     **/
     $array08 = new ArrayObject(array());
     $array10 = new ArrayObject(array());
     $array14 = new ArrayObject(array());
     $array16 = new ArrayObject(array());
     for ($i = 0; $i < count($arrayTemp); $i++) {
         if ($arrayTemp[$i]->Heure->getHoraireDebut() == "16H30") {
             $array16->append($arrayTemp[$i]);
         }
         if ($arrayTemp[$i]->Heure->getHoraireDebut() == "14H30") {
             $array14->append($arrayTemp[$i]);
         }
         if ($arrayTemp[$i]->Heure->getHoraireDebut() == "10H00") {
             $array10->append($arrayTemp[$i]);
         }
         if ($arrayTemp[$i]->Heure->getHoraireDebut() == "08H00") {
             $array08->append($arrayTemp[$i]);
         }
     }
     //		var_dump(count($array08));
     //		var_dump(count($array10));
     //		var_dump(count($array14));
     //		var_dump(count($array16));
     $allarray = array($array08, $array10, $array14, $array16);
     $max = 0;
     for ($i = 1; $i < count($allarray); $i++) {
         if (count($allarray[$max]) < count($allarray[$i])) {
             $max = $i;
         }
     }
     //echo "le max est : ".count($allarray[$max])." et indice : ".$max;
     $arraymax = $allarray[$max];
     for ($i = 0; $i < count($arraymax); $i++) {
         for ($y = 1; $y <= 6; $y++) {
             $makefunction = "makeJour" . $y;
             $jourLibelle = $JourFactory->{$makefunction}();
             //var_dump($jourLibelle);
             if ($jourLibelle == "Mercredi" || $jourLibelle == "Samedi") {
                 $length08 = $array08->count();
                 $key08 = rand(0, $length08);
                 //$key08 = 0;
                 $length10 = $array10->count();
                 $key10 = rand(0, $length10);
                 $aff08 = null;
                 $aff10 = null;
                 if ($array08->offsetExists($key08) == true) {
                     $aff08 = $array08[$key08];
                     $array08->offsetUnset($key08);
                     $array08->exchangeArray($array08->getArrayCopy());
                     //						echo "08H00 : ".$key08.",",PHP_EOL;
                 }
                 if ($array10->offsetExists($key10) == true) {
                     $aff10 = $array10[$key10];
                     $array10->offsetUnset($key10);
                     //						echo "10H00 : ".$key10.",",PHP_EOL;
                 }
                 if (!is_null($aff08) || !is_null($aff10)) {
                     array_push($this->JoursList, new Jour($jourLibelle, array($aff08, $aff10)));
                 }
                 //$array08->offsetUnset($key08);
             } else {
                 $length08 = $array08->count();
                 $key08 = rand(0, $length08);
                 //$key08 = 0;
                 $length10 = $array10->count();
                 $key10 = rand(0, $length10);
                 $length14 = $array14->count();
                 $key14 = rand(0, $length14);
                 $length16 = $array16->count();
                 $key16 = rand(0, $length16);
                 $aff08 = null;
                 $aff10 = null;
                 $aff14 = null;
                 $aff16 = null;
                 if ($array08->offsetExists($key08) == true) {
                     $aff08 = $array08[$key08];
                     $array08->offsetUnset($key08);
                     //$array08->exchangeArray($array08->getArrayCopy());
                     //						echo "08H00 : ".$key08.",",PHP_EOL;
                 }
                 if ($array10->offsetExists($key10) == true) {
                     $aff10 = $array10[$key10];
                     $array10->offsetUnset($key10);
                     //						echo "10H00 : ".$key10.",",PHP_EOL;
                 }
                 if ($array14->offsetExists($key14) == true) {
                     $aff14 = $array14[$key14];
                     $array14->offsetUnset($key14);
                     //$array14->exchangeArray($array08->getArrayCopy());
                     //						echo "14H30 : ".$key14.",",PHP_EOL;
                 }
                 if ($array16->offsetExists($key16) == true) {
                     $aff16 = $array16[$key16];
                     $array16->offsetUnset($key16);
                     //$array14->exchangeArray($array08->getArrayCopy());
                     //						echo "16H30 : ".$key16.",",PHP_EOL;
                 }
                 //					echo "</br>";
                 //					var_dump($aff08);
                 //					var_dump($aff10);
                 //					var_dump($aff14);
                 //					var_dump($aff16);
                 if (!is_null($aff08) || !is_null($aff10) || !is_null($aff14) || !is_null($aff16)) {
                     array_push($this->JoursList, new Jour($jourLibelle, array($aff08, $aff10, $aff14, $aff16)));
                 }
                 //
             }
         }
         //			echo "</br>";
     }
     //		echo "</br>";
     //			var_dump(count($array08));
     //			var_dump(count($array10));
     //			var_dump(count($array14));
     //			var_dump(count($array16));
     //			$this->AffectationRemaining->exchangeArray(array($array08,$array10,$array14,$array16));
     //			echo "</br>";
     //var_dump(count($this->JoursList));
     //var_dump($this->JoursList[5]->Affectations);
     //var_dump($this->JoursList[5]->LibelleJour);
     //var_dump(($array08));
     //var_dump(count($array08));
     //var_dump(count($array10));
     //var_dump(count($array14));
     //var_dump(count($array16));
     //echo "</br>";
     $this->distributeHours($array08, $array10, $array14, $array16);
     //var_dump(count($array08));
     //var_dump(count($array10));
     //var_dump(count($array14));
     //var_dump(count($array16));
     //echo "</br>";
     $this->distributeHours($array08, $array10, $array14, $array16);
     //var_dump(count($array08));
     //var_dump(count($array10));
     //var_dump(count($array14));
     //var_dump(count($array16));
     //echo "</br>";
     $this->distributeHours($array08, $array10, $array14, $array16);
     //var_dump(count($array08));
     //var_dump(count($array10));
     //var_dump(count($array14));
     //var_dump(count($array16));
     // don't worry I will found a recursive formula !!!
     //var_dump(count($this->JoursList));
     //var_dump(count(array_chunk($this->JoursList, 6)));
     //var_dump($this->JoursList[4]);
     // and the end we fill the SemaineList or the list of weeks. Oh Yeah !!!
     //$this->SemaineList = array_chunk($this->JoursList, 6);
     //var_dump($this->SemaineList[3]);
 }
Exemplo n.º 21
0
<?php

class Example
{
    public $public = 'prop:public';
    private $prv = 'prop:private';
    protected $prt = 'prop:protected';
}
$arrayobj = new ArrayObject(new Example());
var_dump($arrayobj->count());
$arrayobj = new ArrayObject(array('first', 'second', 'third'));
var_dump($arrayobj->count());
Exemplo n.º 22
0
 /**
  * @param ArrayObject $countable
  */
 function it_should_mismatch_wrong_countable_count($countable)
 {
     $countable->count()->willReturn(5);
     $this->shouldNotThrow()->duringNegativeMatch('haveCount', $countable, array(4));
 }
Exemplo n.º 23
0
 private function returnJson(ArrayObject $listResults)
 {
     $json = '[';
     if ($listResults->count() > 0) {
         foreach ($listResults as $result) {
             $json .= $result->toJson();
             $json .= ',';
         }
         $json = substr($json, 0, -1);
     }
     $json .= ']';
     return $json;
 }
Exemplo n.º 24
0
 public function count()
 {
     return parent::count();
 }
Exemplo n.º 25
0
 /**
  * @param \ArrayObject|array[] $currencies
  */
 protected function setCurrencies($currencies)
 {
     $this->currencies = $currencies;
     if ($currencies->count()) {
         foreach ($currencies as $currency) {
             $this->currenciesOptimized[$currency['id']] = $currency['value'];
         }
     }
 }
Exemplo n.º 26
0
 /**
  * Count the number of Rows
  *
  * @return integer
  *   1 (one) if there is data in the Row and zero otherwise
  *
  * @link
  *   http://php.net/manual/en/countable.count.php Countable::count()
  */
 public function count()
 {
     return $this->storage->count() == 0 ? 0 : 1;
 }
Exemplo n.º 27
0
 /**
  * Count elements of an object
  * @link http://php.net/manual/en/countable.count.php
  * @return int The custom count as an integer.
  * </p>
  * <p>
  * The return value is cast to an integer.
  * @since 5.1.0
  */
 public function count()
 {
     return $this->data->count();
 }
Exemplo n.º 28
0
 /**
  * Count rows
  * 
  * @return integer
  */
 public function count()
 {
     return $this->iterator->count();
 }
Exemplo n.º 29
0
 /**
  * @param \ArrayObject $values
  * @param $delimiter
  * @return string
  */
 private function renderList(\ArrayObject $values, $delimiter)
 {
     $query = "";
     $loop = 1;
     $size = $values->count();
     foreach ($values as $val) {
         $query .= $val;
         if ($loop < $size) {
             $query .= $delimiter;
         }
         $loop++;
     }
     return $query;
 }
Exemplo n.º 30
0
<?php

//This initializes the include path. It prevents the server from having to have the include path preconfigured making it easier to load the scripts onto any machine and have it work right away.
session_start();
$executionPath = str_replace('\\', '/', getcwd());
$path = get_include_path() . PATH_SEPARATOR . $executionPath . '/interface';
$details = new ArrayObject(scandir($executionPath . '/class'));
//Determines if any directories were found and, if so, iterates over the directories.
if ($details->count() > 0) {
    foreach ($details as $interface) {
        if ($interface !== '.' && $interface !== '..') {
            $path .= PATH_SEPARATOR . $executionPath . '/class/' . $interface;
        }
    }
}
$path .= PATH_SEPARATOR . $executionPath . '/function' . PATH_SEPARATOR . $executionPath . '/config' . PATH_SEPARATOR . $executionPath . '/template' . PATH_SEPARATOR . $executionPath . '/function';
set_include_path($path);
date_default_timezone_set('UTC');
ini_set('display_errors', 0);
ini_set('allow_url_fopen', 1);
error_reporting(E_ALL);
$details = null;
//Defines an autoload function used to catch any missing classes, interfaces or functions and load them dynamically as they're called.
require_once 'Autoload.function.php';
spl_autoload_register('Autoload');
//Calls the routing script and begins processing the route of the page.
if ($_GET['q'] != 'favicon.ico') {
    $router = new Route($_GET['q']);
    header("Access-Control-Allow-Origin: http://zeldathon.net");
    echo $router->executePath();
}