public function testShouldMapThreeInvoices() { $invoices = new \ArrayObject(); $invoices->append(new \Entities\SampleInvoice('48,00', '905/IT', '2016020508', '')); $invoices->append(new \Entities\SampleInvoice('15,00', '', '365/PF', '')); $invoices->append(new \Entities\SampleInvoice('85,20', '', '353/PF', '')); $invoices->append(new \Entities\SampleInvoice('100', '666/AA', '2015120508', '')); $payments = new \ArrayObject(); $payments->append(new \Entities\Payment('48,00', 'RO1755898361', 'Arve nr. 905/IT', 'Company OÜ')); $payments->append(new \Entities\Payment('15,00', 'RO1756686260', 'Tellimus 365/PF', 'Firma AS')); $payments->append(new \Entities\Payment('85,20', 'RO1757162444', 'tellimus 353/PF 24,12,15', 'ISA JA POJAD OÜ')); $payments->append(new \Entities\Payment('100.80', '2016010700183611-1', 'Arve nr. 8/NE', 'EXPERDID OÜ')); $payments->append(new \Entities\Payment('196.99', 'RO1757164672', 'Tellimus', 'AS OÜ')); $payments->append(new \Entities\Payment('10.50', '2016020700153611-1', '-', 'kiiredjavihased OÜ')); $extractorMock = m::mock('extractor'); $extractorMock->shouldReceive('extractPayments')->times(1); $extractorMock->shouldReceive('getPayments')->times(1)->andReturn($payments); $this->_mapper->setExtractor($extractorMock); $mapped = $this->_mapper->map($invoices, 'file_is_mocked.csv', 'TH6'); $this->assertEquals(3, $mapped->count()); for ($i = 0; $i < 3; $i++) { $this->assertEquals($invoices->offsetGet($i), $mapped->offsetGet($i)->getRelatedInvoice()); $this->assertEquals($invoices->offsetGet($i)->getAmount(), $mapped->offsetGet($i)->getAmount()); } }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('Exporting databases'); $io->section('Exporting all databases'); $strategies = $this->collectorDbStrategy->collectDatabasesStrategies(); $totalStrategies = count($strategies); $io->writeln($totalStrategies . ' strategie(s) found.'); $progressBar = new ProgressBar($output, $totalStrategies); $progressBar->setFormat(self::PROGRESS_BAR_FORMAT); $progressBar->setMessage('Beginning backuping'); $this->eventDispatcher->dispatch(Events::BACKUP_BEGINS, new BackupBeginsEvent($output)); $progressBar->start(); $reportContent = new \ArrayObject(); foreach ($strategies as $strategy) { $strategyIdentifier = $strategy->getIdentifier(); $setProgressBarMessage = function ($message) use($progressBar, $strategyIdentifier) { $message = "[{$strategyIdentifier}] {$message}"; $progressBar->setMessage($message); $progressBar->display(); }; $exportedFiles = $this->processorDatabaseDumper->dump($strategy, $setProgressBarMessage); $reportContent->append("Backuping of the database: {$strategyIdentifier}"); foreach ($exportedFiles as $file) { $filename = $file->getPath(); $reportContent->append("\t→ {$filename}"); } $progressBar->advance(); } $progressBar->finish(); $io->newLine(2); $io->section('Report'); $io->text($reportContent->getArrayCopy()); $this->eventDispatcher->dispatch(Events::BACKUP_ENDS, new BackupEndsEvent($output)); }
/** * Set ID of messages to delete. * * This id was returned after sending message. * * @param $id * @return $this * @throws ActionException */ public function filterById($id) { if (!is_string($id)) { throw new ActionException('Invalid value id'); } $this->id->append($id); return $this; }
/** * Set ID of messages to delete. * * This id was returned after sending message. * * @param $id * @return $this * @throws \TMSolution\SmsBundle\Api\SMSApi\Exception\ActionException */ public function filterById($id) { if (!is_string($id)) { throw new \TMSolution\SmsBundle\Api\SMSApi\Exception\ActionException('Invalid value id'); } $this->id->append($id); return $this; }
/** * @return \Nano\Route\Section\Common * @param string $location * * @throws \Nano\Exception */ public function section($location) { $result = self::create($location); $this->sections->append($result); $result->setParent($this); $result->module($this->module); $result->suffix($this->suffix); return $result; }
/** * @param $data */ function __construct($data) { parent::__construct($data); $this->list = new \ArrayObject(); if (isset($this->obj->list)) { foreach ($this->obj->list as $res) { $this->list->append(new GroupResponse($res)); } } }
/** * @param $data */ function __construct($data) { parent::__construct($data); $this->list = new \ArrayObject(); if (isset($this->obj->list)) { foreach ($this->obj->list as $res) { $this->list->append(new MessageResponse($res->id, $res->points, $res->number, $res->status, $res->error, $res->idx)); } } }
/** * Adds a new Object to Collection * * @param Next\Components\Object $object * Object to add to Collection * * @return Next\Components\Iterator\AbstractCollection * Collection Object (Fluent Interface) */ public function add(Object $object) { if ($this->accept($object)) { // Adding Object... $this->collection->append($object); // ... and a Reference to it $this->references->append($object->getHash()); } return $this; }
/** * @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; }
public function testShouldMatchNone() { $invoices = new \ArrayObject(); $invoice = new \Entities\SampleInvoice('100', '666/AA', '2015120508', ''); $invoices->append($invoice); $payments = new \ArrayObject(); $payments->append(new \Entities\Payment('48,00', 'RO1755898361', 'Arve nr. 905/IT', 'Company OÜ')); $payments->append(new \Entities\Payment('15,00', 'RO1756686260', 'Tellimus 365/PF', 'Firma AS')); $payments->append(new \Entities\Payment('85,20', 'RO1757162444', 'tellimus 353/PF 24,12,15', 'ISA JA POJAD OÜ')); $mapped = $this->comparator->compare($invoices, $payments); $this->assertEquals(0, $mapped->count()); }
/** * Add a tag to the document * @param XmlTag $tag, element to add * @param bool $generateTree, if set to true recreates the original tree structure */ public function addTag(XmlTag $tag, $generateTree = false) { if ($generateTree) { $parent = $this->getTagByTagId($tag->getParentTagId()); if ($parent instanceof XmlTag) { $parent->getChildren()->append($tag); } else { $this->_tags->append($tag); } } else { $this->_tags->append($tag); } }
public static function getDBParams($param) { $dbParams = new \ArrayObject(); switch ($param) { case "oracledb": $dbParams->append(array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'foo')); return $dbParams; break; default: $dbParams->append(array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'foo')); return $dbParams; break; } }
public function append($geoCache) { if ($geoCache instanceof GeoCache) { parent::append($geoCache); $this->isReady = true; } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // Set filters & get data $type = $input->getArgument(self::TYPE_ARGUMENT); if ($type) { $this->productlist->setType($type); } $active = $input->getOption(self::ACTIVE_OPTION); if ($active) { $this->productlist->setStatus(1); } $products = $this->productlist->getProducts(); // If only count, return it if ($input->getOption(self::COUNT_OPTION)) { return $output->writeln(sprintf('Count: %d', $products->getTotalCount())); } // Else prepare data for showing $types = $this->productlist->getProductTypesAssoc(); $rows = new \ArrayObject(); foreach ($products->getItems() as $id => $product) { $rows->append([$product->getId(), $product->getSku(), $product->getName(), $types[$product->getTypeId()]]); } // Output table layout $table = new Table($output); $table->setHeaders(['ID', 'SKU', 'Name', 'Type']); $table->setRows($rows->getArrayCopy()); $table->render(); }
/** * @param string $csv the file pathname * @param bool $object if true, returns array object, otherwise a plain array * @return ArrayObject * @throws Exception */ public static function toArray($csv, $object = true) { if ($object == false) { $array = array(); } else { $array = new ArrayObject(); } if (!file_exists($csv)) { throw new Exception('CSV File not found', 404); } $file = new SplFileObject($csv); $file->setFlags(SplFileObject::READ_CSV); foreach ($file as $data) { $count = count($data); if ($object == false) { $item = array(); } else { $item = new ArrayObject(); } for ($x = 0; $x < $count; $x++) { if ($item instanceof ArrayObject) { $item->append($data[$x]); } else { array_push($item, $data[$x]); } } if ($array instanceof ArrayObject) { $array->append($item); } else { array_push($array, $item); } } return $array; }
/** * @param Ticket $ticket * @throws \InvalidArgumentException */ public function append($ticket) { if (!$ticket instanceof Ticket) { throw new \InvalidArgumentException("An instance of Tufesa\\Service\\Type\\Ticket is required"); } parent::append($ticket); }
/** * Parse stream and return array object of parsed payments * * @param string $stream Stream of data to parse to payments * @return \ArrayObject * @throws \Exception when format is unrecognized */ public function parseData($stream) { $amountPadding = 6; $paymentNoPadding = 2; $descriptionPadding = 9; $payerNamePadding = 7; $result = new \ArrayObject(); $rows = explode(PHP_EOL, $stream); $trimmedRows = $rows; for ($i = 0; $i < count($trimmedRows); $i++) { if ($trimmedRows[$i] == '#7') { $amount = (int) substr($trimmedRows[$i + $amountPadding], 0, 11) . ',' . substr($trimmedRows[$i + $amountPadding], 11, 2); $paymentNo = trim($trimmedRows[$i + $paymentNoPadding]); $description = trim($trimmedRows[$i + $descriptionPadding]); $payerName = trim($trimmedRows[$i + $payerNamePadding]); $referenceNo = ""; //TODO: in what location is reference no? //multiple invoices paid if ($matches = $this->_getMatches($description)) { foreach ($matches as $match) { $result->append(new Payment($amount, $paymentNo, $match, $payerName, $referenceNo)); } } //skip the entry $i = $i + $trimmedRows[$i + 1]; } } return $result; }
public function append($corrida) { if (!$corrida instanceof Run) { throw new TypeException("A instance of Corrida is required"); } parent::append($corrida); }
/** * Helper function to do the splitting by sentence. Note: one punctuations * mark belongs to the preceding sentence. Whitespace between sentences is * marked as boundary. * * @return void */ private function parseSubjectBySentence() { $i = 0; $j = 0; $count = 0; $delimitersMatches = array(); preg_match_all('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $this->subject, $delimitersMatches); $splittedSentence = preg_split('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $this->subject); if (count($splittedSentence) == 1) { $this->iteratorCache->append(new TextIteratorElement($splittedSentence[0], 0, Functions::strlen($splittedSentence[0]), false)); return; } foreach ($splittedSentence as $currentPart) { $currentPart = preg_replace('/^\\s|\\s$/', '', $currentPart, -1, $count); $whiteSpace = ''; for ($k = 0; $k < $count; $k++) { $whiteSpace .= ' '; } if ($whiteSpace != '') { $this->iteratorCache->append(new TextIteratorElement($whiteSpace, $i, $count, true)); } $i += $count; if ($currentPart != '' && $j < count($delimitersMatches[0])) { $this->iteratorCache->append(new TextIteratorElement($currentPart . $delimitersMatches[0][$j], $i, Functions::strlen($currentPart . $delimitersMatches[0][$j]), false)); $i += Functions::strlen($currentPart . $delimitersMatches[0][$j]); $j++; } elseif ($j < count($delimitersMatches[0])) { $this->iteratorCache->append(new TextIteratorElement($delimitersMatches[0][$j], $i, 1, true)); $i++; $j++; } } }
public function append($ticket) { if (!$ticket instanceof Ticket) { throw new \InvalidArgumentException(); } parent::append($ticket); }
/** * @param Row $row * @throws \InvalidArgumentException */ public function append($row) { if (!$row instanceof Row) { throw new \InvalidArgumentException("An instance of Tufesa\\Service\\Type\\Row is required"); } parent::append($row); }
/** * Appends the value * @param TagableInterface $value <p> * The value being appended. * </p> * @return void */ public function append($value) { if (!$value instanceof TagableInterface) { throw new \InvalidArgumentException('Invalid tagable object'); } parent::append($value); }
/** * {@inheritdoc} * @see ArrayObject::append() */ public function append($value) { if (!$value instanceof AccountRoleObject) { throw new \InvalidArgumentException(sprintf('AccountRoleObject is expected for append() method.')); } parent::append($value); }
/** * Bootstraps the application. * * This method is called after all services are registered * and should be used for "dynamic" configuration (whenever * a service must be requested). */ public function boot(Application $app) { $src = $app->offsetExists('commands.path') ? $app['commands.path'] : $app['path.src']; $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src)); $commands = new \ArrayObject(); /** @var RecursiveDirectoryIterator $dir */ for ($dir->rewind(); $dir->valid(); $dir->next()) { if ($dir->isDot()) { continue; } if ('php' !== $dir->getExtension()) { continue; } $name = $dir->getSubPathname(); $name = substr($name, 0, -4); $className = str_replace(DIRECTORY_SEPARATOR, '\\', $name); $r = new ReflectionClass($className); if ($r->isAbstract() || false === $r->isSubclassOf("Symfony\\Component\\Console\\Command\\Command")) { continue; } $commands->append(new $className()); } /** @noinspection PhpParamsInspection */ $app['console'] = $app->share($app->extend('console', function (Console $console) use($commands) { foreach ($commands as $command) { $console->add($command); } return $console; })); }
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); } } }
/** * @param mixed $customer * @throws \InvalidArgumentException */ public function append($customer) { if (!$customer instanceof Customer) { throw new \InvalidArgumentException("An instance of Tufesa\\Service\\Type\\Customer is required"); } parent::append($customer); }
/** * @param Schedule $schedule * @throws \InvalidArgumentException */ public function append($schedule) { if (!$schedule instanceof Schedule) { throw new \InvalidArgumentException("An instance of Tufesa\\Service\\Type\\Schedule is required"); } parent::append($schedule); }
/** * Method to append an element to the collection * @param tx_crawler_domain_process $subject * @throws InvalidArgumentException * @return void */ public function append($subject) { if (!$subject instanceof tx_crawler_domain_process) { throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!'); } parent::append($subject); }
/** * @param mixed $value */ public function append($value) { if (!is_a($value, $this->allowedClass)) { $this->throwInvalid($value); } return parent::append($value); }
public function append($item) { if ($item instanceof Item) { return parent::append($item); } throw new \Exception('Só pode adicionar um \\Core_Component_Treeview_Item'); }