Skip to content

Commit

Permalink
Add enumerations for valid card types and outputspeech types
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Burkindine committed Mar 11, 2017
1 parent 1eae822 commit 5226243
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 17 deletions.
19 changes: 19 additions & 0 deletions src/Response/Card/CardTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Alexa\Response\Card;

/**
* Class CardTypes
*
* Enumeration of the allowed Alexa card types
*
* @package Alexa\Response\Card
*/
abstract class CardTypes
{
// Constants

const TYPE_SIMPLE = 'Simple';
const TYPE_STANDARD = 'Standard';
const TYPE_LINK_ACCOUNT = 'LinkAccount';
}
7 changes: 2 additions & 5 deletions src/Response/Card/LinkAccountCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Alexa\Response\Card;

use Alexa\Response\Card\CardInterface;
use Alexa\Response\Card\CardTypes;

/**
* Class LinkAccountCard
Expand All @@ -13,10 +14,6 @@
*/
class LinkAccountCard implements CardInterface
{
// Constants

const CARD_TYPE = 'LinkAccount';

// Public Methods

/**
Expand All @@ -27,7 +24,7 @@ class LinkAccountCard implements CardInterface
public function render()
{
return [
'type' => self::CARD_TYPE
'type' => CardTypes::TYPE_LINK_ACCOUNT
];
}
}
5 changes: 2 additions & 3 deletions src/Response/Card/SimpleCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Alexa\Response\Card;

use Alexa\Response\Card\CardInterface;
use Alexa\Response\Card\CardTypes;

/**
* Class SimpleCard
Expand All @@ -15,8 +16,6 @@ class SimpleCard implements CardInterface
{
// Constants

const CARD_TYPE = 'Simple';

const ERROR_TITLE_NOT_SET = 'You must provide a title for the card';
const ERROR_CONTENT_NOT_SET = 'You must provide the content for the card';

Expand Down Expand Up @@ -55,7 +54,7 @@ public function __construct($title, $content)
public function render()
{
return [
'type' => self::CARD_TYPE,
'type' => CardTypes::TYPE_SIMPLE,
'title' => $this->getTitle(),
'content' => $this->getContent()
];
Expand Down
5 changes: 2 additions & 3 deletions src/Response/Card/StandardCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Alexa\Response\Card;

use Alexa\Response\Card\CardInterface;
use Alexa\Response\Card\CardTypes;

/**
* Class StandardCard
Expand All @@ -15,8 +16,6 @@ class StandardCard implements CardInterface
{
// Constants

const CARD_TYPE = 'Standard';

const ERROR_TITLE_NOT_SET = 'You must provide a title.';
const ERROR_TEXT_NOT_SET = 'You must provide card text.';
const ERROR_SMALL_IMAGE_URL_NOT_SET = 'You must provide a small image URL.';
Expand Down Expand Up @@ -67,7 +66,7 @@ public function __construct($title, $text, $smallImageUrl, $largeImageUrl)
public function render()
{
return [
'type' => self::CARD_TYPE,
'type' => CardTypes::TYPE_STANDARD,
'title' => $this->getTitle(),
'text' => $this->getText(),
'image' => [
Expand Down
18 changes: 18 additions & 0 deletions src/Response/OutputSpeech/OutputSpeechTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Alexa\Response\OutputSpeech;

/**
* Class OutputSpeechTypes
*
* Enumeration of the allowed OutputSpeech types
*
* @package Alexa\Response\OutputSpeech
*/
abstract class OutputSpeechTypes
{
// Constants

const TYPE_PLAIN_TEXT = 'PlainText';
const TYPE_SSML = 'SSML';
}
5 changes: 2 additions & 3 deletions src/Response/OutputSpeech/PlainTextOutputSpeech.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Alexa\Response\OutputSpeech;

use Alexa\Response\OutputSpeech\OutputSpeechInterface;
use Alexa\Response\OutputSpeech\OutputSpeechTypes;

/**
* Class PlainTextOutputSpeech
Expand All @@ -15,8 +16,6 @@ class PlainTextOutputSpeech implements OutputSpeechInterface
{
// Constants

const OUTPUT_SPEECH_TYPE = 'PlainText';

const ERROR_TEXT_NOT_SET = 'You must provide output speech text.';

// Fields
Expand Down Expand Up @@ -49,7 +48,7 @@ public function __construct($text)
public function render()
{
return [
'type' => self::OUTPUT_SPEECH_TYPE,
'type' => OutputSpeechTypes::TYPE_PLAIN_TEXT,
'text' => $this->getText()
];
}
Expand Down
5 changes: 2 additions & 3 deletions src/Response/OutputSpeech/SsmlOutputSpeech.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Alexa\Response\OutputSpeech;

use Alexa\Response\OutputSpeech\OutputSpeechInterface;
use Alexa\Response\OutputSpeech\OutputSpeechTypes;

/**
* Class SsmlOutputSpeech
Expand All @@ -15,8 +16,6 @@ class SsmlOutputSpeech implements OutputSpeechInterface
{
// Constants

const OUTPUT_SPEECH_TYPE_SSML = 'SSML';

const ERROR_SSML_NOT_SET = 'You must provide output speech SSML.';

// Fields
Expand Down Expand Up @@ -46,7 +45,7 @@ public function __construct($ssml)
public function render()
{
return [
'type' => self::OUTPUT_SPEECH_TYPE_SSML,
'type' => OutputSpeechTypes::TYPE_SSML,
'ssml' => $this->getSsml()
];
}
Expand Down

0 comments on commit 5226243

Please sign in to comment.