modifs.mineures sans commentaires
This commit is contained in:
parent
c252c076ae
commit
62c0c46f12
|
@ -44,6 +44,11 @@ class ValueException extends UserException {
|
||||||
return new static(self::message(null, $message, $kind, $prefix, " should not be null"));
|
return new static(self::message(null, $message, $kind, $prefix, " should not be null"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final function check_null($value, ?string $kind=null, ?string $prefix=null, ?string $message=null) {
|
||||||
|
if ($value === null) throw static::null($kind, $prefix, $message);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
static final function invalid_kind($value=null, ?string $kind=null, ?string $prefix=null, ?string $message=null): self {
|
static final function invalid_kind($value=null, ?string $kind=null, ?string $prefix=null, ?string $message=null): self {
|
||||||
return new static(self::message($value, $message, $kind, $prefix, " is invalid"));
|
return new static(self::message($value, $message, $kind, $prefix, " is invalid"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class file {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function writer($output, ?string $mode=null, ?callable $func=null): FileWriter {
|
static function writer($output, ?string $mode="w+b", ?callable $func=null): FileWriter {
|
||||||
$file = new FileWriter(self::fix_dash($output), $mode);
|
$file = new FileWriter(self::fix_dash($output), $mode);
|
||||||
if ($func !== null) {
|
if ($func !== null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -22,7 +22,7 @@ trait TAbstractReader {
|
||||||
$params["ss_type"] = "xlsx";
|
$params["ss_type"] = "xlsx";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new $class($reader->tmpName, $params);
|
return new $class($reader->getFile(), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($reader)) {
|
if (is_string($reader)) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace nulib\file\web;
|
||||||
use nulib\cl;
|
use nulib\cl;
|
||||||
use nulib\file\FileReader;
|
use nulib\file\FileReader;
|
||||||
use nulib\os\path;
|
use nulib\os\path;
|
||||||
|
use nulib\os\sh;
|
||||||
use nulib\php\coll\BaseArray;
|
use nulib\php\coll\BaseArray;
|
||||||
use nulib\ValueException;
|
use nulib\ValueException;
|
||||||
|
|
||||||
|
@ -103,6 +104,7 @@ class Upload extends BaseArray {
|
||||||
|
|
||||||
function moveTo(string $dest): bool {
|
function moveTo(string $dest): bool {
|
||||||
if ($this->file === null) {
|
if ($this->file === null) {
|
||||||
|
sh::mkdirof($dest);
|
||||||
$moved = move_uploaded_file($this->tmpName, $dest);
|
$moved = move_uploaded_file($this->tmpName, $dest);
|
||||||
if ($moved) $this->file = $dest;
|
if ($moved) $this->file = $dest;
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,8 +113,11 @@ class Upload extends BaseArray {
|
||||||
return $moved;
|
return $moved;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFile(): FileReader {
|
function getFile(): string {
|
||||||
$file = $this->file ?? $this->tmpName;
|
return $this->file ?? $this->tmpName;
|
||||||
return new FileReader($file, "r+b");
|
}
|
||||||
|
|
||||||
|
function getReader(): FileReader {
|
||||||
|
return new FileReader($this->getFile(), "r+b");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue