Skip to content

Commit

Permalink
Upgrade to mekras/atom 0.3.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
mekras committed Jul 12, 2016
1 parent 3b7fa56 commit c8bde03
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"prefer-stable": true,
"require": {
"php": ">=5.6",
"mekras/atom": "~0.2",
"mekras/atom": "~0.3.1",
"mekras/class-helpers": "^1.2"
},
"require-dev": {
Expand Down
32 changes: 18 additions & 14 deletions src/Document/CategoryDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ class CategoryDocument extends Document
*
* @return bool
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function isFixed()
{
return $this->getCachedProperty(
'fixed',
function () {
return $this->getDomElement()->getAttribute('fixed') === 'yes';
return $this->getAttribute('fixed') === 'yes';
}
);
}
Expand All @@ -42,11 +44,13 @@ function () {
*
* @param bool $state
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function setFixed($state)
{
$this->getDomElement()->setAttribute('fixed', $state ? 'yes' : 'no');
$this->setAttribute('fixed', $state ? 'yes' : 'no');
$this->setCachedProperty('fixed', $state);
}

Expand All @@ -55,14 +59,16 @@ public function setFixed($state)
*
* @return string|null
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function getScheme()
{
return $this->getCachedProperty(
'scheme',
function () {
return $this->getDomElement()->getAttribute('scheme') ?: null;
return $this->getAttribute('scheme');
}
);
}
Expand All @@ -72,15 +78,13 @@ function () {
*
* @param string|null $iri Scheme IRI.
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function setScheme($iri)
{
if (null === $iri) {
$this->getDomElement()->removeAttribute('scheme');
} else {
$this->getDomElement()->setAttribute('scheme', $iri);
}
$this->setAttribute('scheme', $iri);
$this->setCachedProperty('scheme', $iri);
}

Expand All @@ -89,14 +93,16 @@ public function setScheme($iri)
*
* @return string|null
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function getHref()
{
return $this->getCachedProperty(
'href',
function () {
return $this->getDomElement()->getAttribute('href') ?: null;
return $this->getAttribute('href');
}
);
}
Expand All @@ -106,15 +112,13 @@ function () {
*
* @param string|null $iri IRI.
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function setHref($iri)
{
if (null === $iri) {
$this->getDomElement()->removeAttribute('href');
} else {
$this->getDomElement()->setAttribute('href', $iri);
}
$this->setAttribute('href', $iri);
$this->setCachedProperty('href', $iri);
}

Expand Down
10 changes: 7 additions & 3 deletions src/Element/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,29 @@ class Collection extends Element
/**
* The IRI of the Collection.
*
* @return string
* @return string|null
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function getHref()
{
return $this->getDomElement()->getAttribute('href');
return $this->getAttribute('href');
}

/**
* Set IRI of the Collection.
*
* @param string $href
*
* @throws \InvalidArgumentException
*
* @since 1.0
*/
public function setHref($href)
{
$this->getDomElement()->setAttribute('href', $href);
$this->setAttribute('href', $href);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Document/CategoryDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testCreate()
$document = new CategoryDocument($this->createExtensions());
$document->setFixed(false);
$document->setScheme('http://example.com/cats/big3');
$document->setHref(null);
//$document->setHref(null);
$document->addCategory('animal');
$document->addCategory('vegetable');
$document->addCategory('mineral');
Expand Down

0 comments on commit c8bde03

Please sign in to comment.