Skip to content

Commit

Permalink
Update parser, added xsd validation, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lireincore committed Sep 12, 2016
1 parent dcc442b commit 303183b
Show file tree
Hide file tree
Showing 20 changed files with 1,244 additions and 410 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,20 @@ $ composer require lireincore/ymlparser
use LireinCore\YMLParser\YML;

$yml = new YML();
$yml->parse($filepath);
$date = $yml->getDate();
$shop = $yml->getShop();
/**@var \LireinCore\YMLParser\Offer\AOffer $offer*/
foreach ($yml->getOffers() as $offer) {
try {
$yml->parse($filepath);
$date = $yml->getDate();
$shop = $yml->getShop();
/**@var \LireinCore\YMLParser\Offer\AOffer $offer*/
foreach ($yml->getOffers() as $offer) {
$offerCategoryHierarchy = $shop->getCategoryHierarchy($offer->getCategoryId);
//...
}
} catch (\Exception $e) {
//...
}
```

## Testing

``` bash
$ phpunit
```

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": ">=5.4"
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": ">=4.0"
Expand Down
92 changes: 0 additions & 92 deletions example.xml

This file was deleted.

37 changes: 19 additions & 18 deletions src/Offer/ABookOffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace LireinCore\YMLParser\Offer;

abstract class ABookOffer extends ABaseOffer
abstract class ABookOffer extends AExtOffer
{
/**
* @var string
*/
protected $name;
protected $author;

/**
* @var string
*/
protected $author;
protected $name;

/**
* @var string
Expand Down Expand Up @@ -50,54 +50,55 @@ abstract class ABookOffer extends ABaseOffer
protected $language;

/**
* @var
* @var string
*/
protected $tableOfContents; //todo property type
protected $tableOfContents;

/**
* @return array
*/
public function getFiledsList()
public function getAttributesList()
{
return array_merge(parent::getFiledsList(), [
return array_merge(parent::getAttributesList(), [
//subnodes
'name', 'author', 'publisher', 'series', 'year', 'ISBN', 'volume', 'part', 'language', 'table_of_contents'
]);
}

/**
* @return string
*/
public function getName()
public function getAuthor()
{
return $this->name;
return $this->author;
}

/**
* @param string $value
* @return $this
*/
public function setName($value)
public function setAuthor($value)
{
$this->name = (string)$value;
$this->author = (string)$value;

return $this;
}

/**
* @return string
*/
public function getAuthor()
public function getName()
{
return $this->author;
return $this->name;
}

/**
* @param string $value
* @return $this
*/
public function setAuthor($value)
public function setName($value)
{
$this->author = (string)$value;
$this->name = (string)$value;

return $this;
}
Expand Down Expand Up @@ -236,20 +237,20 @@ public function setLanguage($value)
}

/**
* @return mixed
* @return string
*/
public function getTableOfContents()
{
return $this->tableOfContents;
}

/**
* @param $value
* @param string $value
* @return $this
*/
public function setTableOfContents($value)
{
$this->tableOfContents = $value; //todo type?
$this->tableOfContents = (string)$value;

return $this;
}
Expand Down
Loading

0 comments on commit 303183b

Please sign in to comment.