Skip to content

Commit

Permalink
GitHub #82 - Add getType method on group
Browse files Browse the repository at this point in the history
sqmk committed Dec 22, 2014

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent ffb714e commit b74c8d3
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/list-groups.php
Original file line number Diff line number Diff line change
@@ -13,5 +13,6 @@

foreach ($client->getGroups() as $group) {
echo "\t", "#{$group->getId()} - {$group->getName()}", "\n",
"\t\t Type: ", $group->getType(), "\n",
"\t\t Lights: ", implode(', ', $group->getLightIds()), "\n";
}
14 changes: 12 additions & 2 deletions library/Phue/Group.php
Original file line number Diff line number Diff line change
@@ -43,9 +43,9 @@ class Group
/**
* Construct a Phue Group object
*
* @param int $id Id
* @param int $id Id
* @param \stdClass $attributes Group attributes
* @param Client $client Phue client
* @param Client $client Phue client
*/
public function __construct($id, \stdClass $attributes, Client $client)
{
@@ -74,6 +74,16 @@ public function getName()
return $this->attributes->name;
}

/**
* Get type
*
* @return string Group type
*/
public function getType()
{
return $this->attributes->type;
}

/**
* Set name of group
*
16 changes: 15 additions & 1 deletion tests/Phue/Test/GroupTest.php
Original file line number Diff line number Diff line change
@@ -42,7 +42,8 @@ public function setUp()
'colormode' => 'hs',
'effect' => 'none',
],
'lights' => [2, 3, 5]
'lights' => [2, 3, 5],
'type' => 'LightGroup',
];

// Create group object
@@ -104,6 +105,19 @@ public function testSetName()
);
}

/**
* Test: Get type
*
* @covers \Phue\Group::getType
*/
public function testGetType()
{
$this->assertEquals(
$this->attributes->type,
$this->group->getType()
);
}

/**
* Test: Get light ids
*

0 comments on commit b74c8d3

Please sign in to comment.