-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from travello-gmbh/26-support-for-echo-show
Add Hint directive
- Loading branch information
Showing
5 changed files
with
108 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* PHP Library for Amazon Alexa Skills | ||
* | ||
* @author Ralf Eggert <ralf@travello.audio> | ||
* @license http://opensource.org/licenses/MIT The MIT License (MIT) | ||
* @link https://github.com/travello-gmbh/amazon-alexa-skill-library | ||
* @link https://www.travello.audio/ | ||
* | ||
*/ | ||
|
||
namespace TravelloAlexaLibrary\Response\Directives\Hint; | ||
|
||
use TravelloAlexaLibrary\Response\Directives\DirectivesInterface; | ||
|
||
/** | ||
* Class Hint | ||
* | ||
* @package TravelloAlexaLibrary\Response\Directives\Hint | ||
*/ | ||
class Hint implements DirectivesInterface | ||
{ | ||
/** Type of directive */ | ||
const DIRECTIVE_TYPE = 'Hint'; | ||
|
||
/** @var string */ | ||
private $text; | ||
|
||
/** | ||
* Hint constructor. | ||
* | ||
* @param string $text | ||
*/ | ||
public function __construct(string $text) | ||
{ | ||
$this->text = $text; | ||
} | ||
|
||
/** | ||
* Get the directive type | ||
* | ||
* @return string | ||
*/ | ||
public function getType(): string | ||
{ | ||
return self::DIRECTIVE_TYPE; | ||
} | ||
|
||
/** | ||
* Render the directives object to an array | ||
* | ||
* @return array | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'type' => self::DIRECTIVE_TYPE, | ||
'hint' => [ | ||
'type' => 'PlainText', | ||
'text' => $this->text, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* PHP Library for Amazon Alexa Skills | ||
* | ||
* @author Ralf Eggert <ralf@travello.audio> | ||
* @license http://opensource.org/licenses/MIT The MIT License (MIT) | ||
* @link https://github.com/travello-gmbh/amazon-alexa-skill-library | ||
* @link https://www.travello.audio/ | ||
* | ||
*/ | ||
|
||
namespace TravelloAlexaLibraryTest\Response\Directives\Hint; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use TravelloAlexaLibrary\Response\Directives\Hint\Hint; | ||
|
||
/** | ||
* Class HintTest | ||
* | ||
* @package TravelloAlexaLibraryTest\Response\Directives\Hint; | ||
*/ | ||
class HintTest extends TestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function testWithMandatoryOnly() | ||
{ | ||
$hint = new Hint('this is a text'); | ||
|
||
$expected = [ | ||
'type' => 'Hint', | ||
'hint' => [ | ||
'type' => 'PlainText', | ||
'text' => 'this is a text', | ||
], | ||
]; | ||
|
||
$this->assertEquals($expected, $hint->toArray()); | ||
} | ||
} |