This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
387 additions
and
241 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository | ||
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com) | ||
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
namespace Zend\Diactoros; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* Create an uploaded file instance from an array of values. | ||
* | ||
* @param array $spec A single $_FILES entry. | ||
* @return UploadedFile | ||
* @throws InvalidArgumentException if one or more of the tmp_name, size, | ||
* or error keys are missing from $spec. | ||
*/ | ||
function createUploadedFile(array $spec) | ||
{ | ||
if (! isset($spec['tmp_name']) | ||
|| ! isset($spec['size']) | ||
|| ! isset($spec['error']) | ||
) { | ||
throw new InvalidArgumentException(sprintf( | ||
'$spec provided to %s MUST contain each of the keys "tmp_name",' | ||
. ' "size", and "error"; one or more were missing', | ||
__FUNCTION__ | ||
)); | ||
} | ||
|
||
return new UploadedFile( | ||
$spec['tmp_name'], | ||
$spec['size'], | ||
$spec['error'], | ||
$spec['name'] ?? null, | ||
$spec['type'] ?? null | ||
); | ||
} |
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,26 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository | ||
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com) | ||
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
namespace Zend\Diactoros; | ||
|
||
/** | ||
* @param string $name | ||
* @param array $headers Array of headers | ||
* @param mixed $default Default value to return if $name not found in $headers. | ||
* @return mixed | ||
*/ | ||
function getHeaderFromArray($name, array $headers, $default = null) | ||
{ | ||
$header = strtolower($name); | ||
$headers = array_change_key_case($headers, CASE_LOWER); | ||
if (array_key_exists($header, $headers)) { | ||
$value = is_array($headers[$header]) ? implode(', ', $headers[$header]) : $headers[$header]; | ||
return $value; | ||
} | ||
|
||
return $default; | ||
} |
Oops, something went wrong.