Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
82
vendor/doctrine/rst-parser/lib/Builder/Copier.php
vendored
Normal file
82
vendor/doctrine/rst-parser/lib/Builder/Copier.php
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\Builder;
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
use function basename;
|
||||
use function dirname;
|
||||
use function is_dir;
|
||||
|
||||
final class Copier
|
||||
{
|
||||
/** @var Filesystem */
|
||||
private $filesystem;
|
||||
|
||||
/** @var string[][] */
|
||||
private $toCopy = [];
|
||||
|
||||
/** @var string[] */
|
||||
private $toMkdir = [];
|
||||
|
||||
public function __construct(Filesystem $filesystem)
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
|
||||
public function doCopy(string $sourceDirectory, string $targetDirectory): void
|
||||
{
|
||||
foreach ($this->toCopy as $copy) {
|
||||
[$source, $destination] = $copy;
|
||||
|
||||
if ($source[0] !== '/') {
|
||||
$source = $sourceDirectory . '/' . $source;
|
||||
}
|
||||
|
||||
$destination = $targetDirectory . '/' . $destination;
|
||||
|
||||
if (is_dir($source) && is_dir($destination)) {
|
||||
$destination = dirname($destination);
|
||||
}
|
||||
|
||||
if (is_dir($source)) {
|
||||
$this->filesystem->mirror($source, $destination);
|
||||
} else {
|
||||
$this->filesystem->copy($source, $destination);
|
||||
}
|
||||
}
|
||||
|
||||
$this->toCopy = [];
|
||||
}
|
||||
|
||||
public function doMkdir(string $targetDirectory): void
|
||||
{
|
||||
foreach ($this->toMkdir as $mkdir) {
|
||||
$dir = $targetDirectory . '/' . $mkdir;
|
||||
|
||||
if (is_dir($dir)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->filesystem->mkdir($dir, 0755);
|
||||
}
|
||||
|
||||
$this->toMkdir = [];
|
||||
}
|
||||
|
||||
public function copy(string $source, ?string $destination = null): void
|
||||
{
|
||||
if ($destination === null) {
|
||||
$destination = basename($source);
|
||||
}
|
||||
|
||||
$this->toCopy[] = [$source, $destination];
|
||||
}
|
||||
|
||||
public function mkdir(string $directory): void
|
||||
{
|
||||
$this->toMkdir[] = $directory;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue