Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getBaseName example
return
Time::
now
(
)
->
getTimestamp
(
)
. '_' .
bin2hex
(
random_bytes
(
10
)
)
.
$extension
;
}
/** * Moves a file to a new location. * * @return File */
public
function
move
(
string
$targetPath
, ?string
$name
= null, bool
$overwrite
= false
)
{
$targetPath
=
rtrim
(
$targetPath
, '/'
)
. '/';
$name
??=
$this
->
getBaseName
(
)
;
$destination
=
$overwrite
?
$targetPath
.
$name
:
$this
->
getDestination
(
$targetPath
.
$name
)
;
$oldName
=
$this
->
getRealPath
(
)
?:
$this
->
__toString
(
)
;
if
(
! @
rename
(
$oldName
,
$destination
)
)
{
$error
=
error_get_last
(
)
;
throw
FileException::
forUnableToMove
(
$this
->
getBasename
(
)
,
$targetPath
,
strip_tags
(
$error
[
'message'
]
)
)
;
}
@
chmod
(
$destination
, 0777 & ~
umask
(
)
)
;