-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- remove configuration validate from helper class and create a configuration validator class to validate the configurations - rename $required_configurations to $rules in the amazon provider class Fix #12
- Loading branch information
mahmoud
committed
Sep 5, 2014
1 parent
e91cb53
commit fea73ac
Showing
4 changed files
with
82 additions
and
7 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
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,44 @@ | ||
<?php namespace Vinelab\Cdn\Validators; | ||
|
||
/** | ||
* @author Mahmoud Zalt <mahmoud@vinelab.com> | ||
*/ | ||
|
||
use Vinelab\Cdn\Exceptions\MissingConfigurationException; | ||
use Vinelab\Cdn\Validators\Contracts\ConfigurationsInterface; | ||
|
||
/** | ||
* Helper class containing shared functions | ||
* | ||
* Class CdnHelper | ||
This comment has been minimized.
Sorry, something went wrong. |
||
* @package Vinelab\Cdn | ||
*/ | ||
class Configurations implements ConfigurationsInterface{ | ||
|
||
/** | ||
* Checks for any required configuration is missed | ||
* | ||
* @param $configuration | ||
* @param $required | ||
* | ||
* @throws \Vinelab\Cdn\Exceptions\MissingConfigurationException | ||
*/ | ||
public function validate($configuration, $required) | ||
{ | ||
// search for any null or empty field to throw an exception | ||
$missing = ''; | ||
foreach ($configuration as $key => $value) { | ||
|
||
if (in_array($key, $required) && | ||
(empty($value) || $value == null || $value == '')) | ||
{ | ||
$missing .= ' ' . $key; | ||
} | ||
} | ||
|
||
if ($missing) | ||
throw new MissingConfigurationException("Missed Configuration:" . $missing); | ||
|
||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/Vinelab/Cdn/Validators/Contracts/ConfigurationsInterface.php
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,9 @@ | ||
<?php namespace Vinelab\Cdn\Validators\Contracts; | ||
|
||
/** | ||
* @author Mahmoud Zalt <mahmoud@vinelab.com> | ||
*/ | ||
|
||
interface ConfigurationsInterface{ | ||
|
||
} |
not the correct class description