Skip to content

Commit 4c0a334

Browse files
committed
Consistent documentation and no return value for removeAttribute()
1 parent 9d48cfc commit 4c0a334

11 files changed

Lines changed: 36 additions & 38 deletions

src/Attribute/AttributeAware.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ public function getAttribute($name, $default = null);
2727
public function setAttribute($name, $value);
2828

2929
/**
30-
* @param $name
31-
* @return mixed
30+
* Removes a single attribute with the given $name
31+
*
32+
* @param string $name
3233
*/
3334
public function removeAttribute($name);
3435

src/Attribute/AttributeBag.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface AttributeBag extends AttributeAware
99
{
1010
// public function getAttribute($name, $default);
1111
// public function setAttribute($name, $value);
12+
// public function removeAttribute();
1213
// public function getAttributeBag();
1314

1415
/**

src/Attribute/AttributeBagContainer.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,13 @@ public function setAttribute($name, $value)
4242
}
4343

4444
/**
45-
* remove a single attribute with the given $name
45+
* Removes a single attribute with the given $name
4646
*
47-
* @param $name
48-
* @return $this
47+
* @param string $name
4948
*/
5049
public function removeAttribute($name)
5150
{
52-
if (isset($this->attributes[$name]) === true) {
53-
unset($this->attributes[$name]);
54-
}
55-
56-
return $this;
51+
unset($this->attributes[$name]);
5752
}
5853

5954
/**

src/Attribute/AttributeBagNamespaced.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,13 @@ public function setAttribute($name, $value)
6969
}
7070

7171
/**
72-
* remove a single attribute with the given $name
72+
* Removes a single attribute with the given $name
7373
*
74-
* @param $name
75-
* @return $this
74+
* @param string $name
7675
*/
7776
public function removeAttribute($name)
7877
{
79-
if (isset($this->attributes[$name]) === true) {
80-
unset($this->attributes[$name]);
81-
}
82-
83-
return $this;
78+
$this->bag->removeAttribute($this->prefix . $name);
8479
}
8580

8681
/**

src/Attribute/AttributeBagReference.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,13 @@ public function setAttribute($name, $value)
5656
}
5757

5858
/**
59-
* remove a single attribute with the given $name
59+
* Removes a single attribute with the given $name
6060
*
61-
* @param $name
62-
* @return $this
61+
* @param string $name
6362
*/
6463
public function removeAttribute($name)
6564
{
66-
if (isset($this->attributes[$name]) === true) {
67-
unset($this->attributes[$name]);
68-
}
69-
70-
return $this;
65+
unset($this->attributes[$name]);
7166
}
7267

7368
/**

src/Edge/Base.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,7 @@ public function setAttribute($name, $value)
305305

306306
public function removeAttribute($name)
307307
{
308-
if (isset($this->attributes[$name]) === true) {
309-
unset($this->attributes[$name]);
310-
}
308+
unset($this->attributes[$name]);
311309
}
312310

313311
public function getAttributeBag()

src/Graph.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,7 @@ public function setAttribute($name, $value)
464464

465465
public function removeAttribute($name)
466466
{
467-
if (isset($this->attributes[$name]) === true) {
468-
unset($this->attributes[$name]);
469-
}
467+
unset($this->attributes[$name]);
470468
}
471469

472470
public function getAttributeBag()

src/Vertex.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,7 @@ public function setAttribute($name, $value)
384384

385385
public function removeAttribute($name)
386386
{
387-
if (isset($this->attributes[$name]) === true) {
388-
unset($this->attributes[$name]);
389-
}
387+
unset($this->attributes[$name]);
390388
}
391389

392390
public function getAttributeBag()

tests/Attribute/AttributeBagContainerTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
use Fhaculty\Graph\Attribute\AttributeBagContainer;
44

5-
class AttributeBagContainerTest extends TestCase
5+
class AttributeBagContainerTest extends AbstractAttributeAwareTest
66
{
7+
protected function createAttributeAware()
8+
{
9+
return new AttributeBagContainer();
10+
}
11+
712
public function testEmpty()
813
{
914
$bag = new AttributeBagContainer();

tests/Attribute/AttributeBagNamespacedTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
use Fhaculty\Graph\Attribute\AttributeAware;
66
use Fhaculty\Graph\Attribute\AttributeBagContainer;
77

8-
class AtributeBagNamespacedTest extends TestCase
8+
class AtributeBagNamespacedTest extends AbstractAttributeAwareTest
99
{
10+
protected function createAttributeAware()
11+
{
12+
return new AttributeBagNamespaced(new AttributeBagContainer(), 'test.');
13+
}
14+
1015
public function testBagContainer()
1116
{
1217
$container = new AttributeBagContainer();

0 commit comments

Comments
 (0)