Skip to content

Commit

Permalink
Using constants for parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
felixgirault committed May 10, 2015
1 parent 16e2635 commit aebf4d7
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 32 deletions.
55 changes: 23 additions & 32 deletions lib/Multiplayer/Multiplayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
namespace Multiplayer;

use Multiplayer\Param;



/**
Expand Down Expand Up @@ -33,28 +35,17 @@ class Multiplayer {
/**
* A set of generic parameters.
*
* ### Options
*
* - 'autoPlay' boolean Whether or not to start the video when it is loaded.
* - 'showInfos' boolean
* - 'showBranding' boolean
* - 'showRelated' boolean Whether or not to show related videos at the end.
* - 'backgroundColor' string Hex code of the player's background color.
* - 'foregroundColor' string Hex code of the player's foreground color.
* - 'highlightColor' string Hex code of the player's highlight color.
* - 'start' int The number of seconds at which the video must start.
*
* @var array
*/
protected $_params = [
'autoPlay' => null,
'showInfos' => null,
'showBranding' => null,
'showRelated' => null,
'backgroundColor' => null,
'foregroundColor' => null,
'highlightColor' => null,
'start' => null
Param::autoPlay => null,
Param::showInfos => null,
Param::showBranding => null,
Param::showRelated => null,
Param::backgroundColor => null,
Param::foregroundColor => null,
Param::highlightColor => null,
Param::start => null
];


Expand All @@ -77,19 +68,19 @@ class Multiplayer {
'id' => '#dailymotion\.com/(?:embed/)?video/(?<id>[a-z0-9]+)#i',
'url' => '//www.dailymotion.com/embed/video/%s',
'map' => [
'autoPlay' => 'autoplay',
'showInfos' => 'info',
'showBranding' => 'logo',
'showRelated' => 'related',
'backgroundColor' => [
Param::autoPlay => 'autoplay',
Param::showInfos => 'info',
Param::showBranding => 'logo',
Param::showRelated => 'related',
Param::backgroundColor => [
'prefix' => '#',
'param' => 'background'
],
'foregroundColor' => [
Param::foregroundColor => [
'prefix' => '#',
'param' => 'foreground'
],
'highlightColor' => [
Param::highlightColor => [
'prefix' => '#',
'param' => 'highlight'
],
Expand All @@ -99,18 +90,18 @@ class Multiplayer {
'id' => '#vimeo\.com/(?:video/)?(?<id>[0-9]+)#i',
'url' => '//player.vimeo.com/video/%s',
'map' => [
'autoPlay' => 'autoplay',
'showInfos' => ['byline', 'portrait'],
'foregroundColor' => 'color'
Param::autoPlay => 'autoplay',
Param::showInfos => ['byline', 'portrait'],
Param::foregroundColor => 'color'
]
],
'youtube' => [
'id' => '#(?:youtu\.be/|youtube.com/(?:v/|embed/|watch\?v=))(?<id>[a-z0-9_-]+)#i',
'url' => '//www.youtube-nocookie.com/embed/%s',
'map' => [
'autoPlay' => 'autoplay',
'showInfos' => 'showinfo',
'showRelated' => 'rel'
Param::autoPlay => 'autoplay',
Param::showInfos => 'showinfo',
Param::showRelated => 'rel'
]
]
];
Expand Down
86 changes: 86 additions & 0 deletions lib/Multiplayer/Param.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

/**
* @author Félix Girault <felix.girault@gmail.com>
* @license FreeBSD License (http://opensource.org/licenses/BSD-2-Clause)
*/
namespace Multiplayer;



/**
* A set of generic parameters.
*/
class Param {

/**
* Whether or not to start the video when it is loaded.
*
* @var string
*/
const autoPlay = 'autoPlay';



/**
*
*
* @var string
*/
const showInfos = 'showInfos';



/**
*
*
* @var string
*/
const showBranding = 'showBranding';



/**
* Whether or not to show related videos at the end.
*
* @var string
*/
const showRelated = 'showRelated';



/**
* Hex code of the player's background color.
*
* @var string
*/
const backgroundColor = 'backgroundColor';



/**
* Hex code of the player's foreground color.
*
* @var string
*/
const foregroundColor = 'foregroundColor';



/**
* Hex code of the player's highlight color.
*
* @var string
*/
const highlightColor = 'highlightColor';



/**
* The number of seconds at which the video must start.
*
* @var string
*/
const start = 'start';

}

0 comments on commit aebf4d7

Please sign in to comment.