-
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.
Merge pull request #12 from Vinelab/fix/upload-with-missing-credentials
improve handling missing credentials by fixing missed configuration vali...
- Loading branch information
Showing
7 changed files
with
137 additions
and
27 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
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,42 @@ | ||
<?php namespace Vinelab\Cdn\Validators; | ||
|
||
/** | ||
* @author Mahmoud Zalt <mahmoud@vinelab.com> | ||
*/ | ||
|
||
use Vinelab\Cdn\Exceptions\MissingConfigurationException; | ||
use Vinelab\Cdn\Validators\Contracts\ConfigurationsInterface; | ||
|
||
/** | ||
* Class Configurations | ||
* @package Vinelab\Cdn\Validators | ||
*/ | ||
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{ | ||
|
||
} |