Skip to content

Commit

Permalink
Added 2 new model
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbonachera committed Sep 20, 2017
1 parent 36f1b42 commit 3c9dc13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright {2017} {David Bonachera}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
19 changes: 11 additions & 8 deletions Parser/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,30 @@
*/
namespace Boda\EdiParserBundle\Parser;

use Boda\EdiParserBundle\Model\ModelAbstract;

class Reader
{
/**
* @var array
*/
private $errors = [];

public function parse(array $template = [], array $rows = [], $identifierSize = 5)
public function parse(ModelAbstract $model, array $rows = [], $identifierSize = 5)
{
if (empty($template)) {
$this->errors["template"] = "No template given";
if (empty($model)) {
$this->errors["model"] = "No model given";
return false;
}
// Init array
$myArray = [];
// SubBody counter
$j = 0;
$myArray["header"] = $this->formatLine($template["header"], $rows[0]);
$myArray["header"] = $this->formatLine($model->getHeader(), $rows[0]);
for ($i = 1; $i < count($rows) - 1; $i++) {
foreach ($template["body"] as $index => $templateSubBody) {
if (substr($rows[$i], 0, $identifierSize) === $index) {
foreach ($model->getData() as $index => $templateSubBody) {
dump($templateSubBody);
/*if (substr($rows[$i], 0, $identifierSize) === $index) {
$myArray["body"][$j][] = $this->formatLine($templateSubBody, $rows[$i]);
$j++;
continue;
Expand All @@ -42,11 +45,11 @@ public function parse(array $template = [], array $rows = [], $identifierSize =
$myArray["body"][$j][] = $this->formatLine($templateSubBody2, $rows[$i]);
}
}
}
}*/
}
continue;
}
$myArray["footer"] = $this->formatLine($template["footer"], $rows[count($rows) - 1]);
$myArray["footer"] = $this->formatLine($model->getFooter(), $rows[count($rows) - 1]);
return $myArray;
}

Expand Down

0 comments on commit 3c9dc13

Please sign in to comment.