Optimisations

- Fixed issue with `InputFile` not setting file-name properly.
- Fixed issue with `InputFile` not setting the correct index when
posting certain arrays.
- Made Csrf-token cookie provider more versitile by creating new
`CookieTokenProvider` and `ITokenProvider` classes.
- Strict-checks optimisations.
- Updated documentation to reflect new changes.
This commit is contained in:
Simon Sessingø
2017-11-26 17:32:33 +01:00
parent b9aa348b38
commit 35dc26d741
13 changed files with 211 additions and 88 deletions
+6 -4
View File
@@ -16,7 +16,7 @@ class InputFile implements IInputItem
$this->index = $index;
// Make the name human friendly, by replace _ with space
$this->name = ucfirst(str_replace('_', ' ', $this->index));
$this->name = ucfirst(str_replace('_', ' ', strtolower($this->index)));
}
/**
@@ -28,7 +28,7 @@ class InputFile implements IInputItem
*/
public static function createFromArray(array $values)
{
if (!isset($values['index'])) {
if (array_key_exists('index', $values) === false) {
throw new \InvalidArgumentException('Index key is required');
}
@@ -39,6 +39,7 @@ class InputFile implements IInputItem
'type' => null,
'size' => null,
'name' => null,
'filename' => null,
'error' => null,
], $values);
@@ -47,7 +48,7 @@ class InputFile implements IInputItem
->setError($values['error'])
->setType($values['type'])
->setTmpName($values['tmp_name'])
->setFilename($values['name']);
->setFilename($values['filename']);
}
@@ -267,8 +268,9 @@ class InputFile implements IInputItem
'tmp_name' => $this->tmpName,
'type' => $this->type,
'size' => $this->size,
'name' => $this->filename,
'name' => $this->name,
'error' => $this->error,
'filename' => $this->filename,
];
}