Skip to content

Commit

Permalink
Merge pull request #33 from travello-gmbh/26-support-for-echo-show
Browse files Browse the repository at this point in the history
Add Hint directive
  • Loading branch information
Ralf Eggert committed Nov 26, 2017
2 parents 9fda9ae + 7d5ccee commit 0d531fa
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/Response/Directives/Display/RenderTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ class RenderTemplate implements DirectivesInterface
/**
* RenderTemplate constructor.
*
* @param string $type
* @param string $token
* @param string $type
* @param string $token
* @param TextContent $textContent
*/
public function __construct(string $type, string $token, TextContent $textContent)
{
Expand Down
64 changes: 64 additions & 0 deletions src/Response/Directives/Hint/Hint.php
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,
],
];
}
}
10 changes: 0 additions & 10 deletions test/Response/Directives/Display/RenderTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
*
*/

/**
* 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\Display;

use PHPUnit\Framework\TestCase;
Expand Down
10 changes: 0 additions & 10 deletions test/Response/Directives/Display/TextContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
*
*/

/**
* 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\Display;

use PHPUnit\Framework\TestCase;
Expand Down
41 changes: 41 additions & 0 deletions test/Response/Directives/Hint/HintTest.php
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());
}
}

0 comments on commit 0d531fa

Please sign in to comment.