diff --git a/backup b/backup index cec3043..8e2ebb5 100755 --- a/backup +++ b/backup @@ -1,26 +1,6 @@ #!/usr/bin/env php + * @license https://opensource.org/licenses/gpl-license.php GNU Public License + * @link https://jcktrue.dk + */ class App { protected Logger $logger; protected array $config; + /** + * Create a new instance providing a config file + * + * @param string $configFile Relative or full path to YML config. + */ function __construct(string $configFile) { $this->config = Yaml::parseFile($configFile); @@ -26,12 +40,21 @@ class App $this->logger = $logger; } - + /** + * Get the full configuration + * + * @return array Full configuration structure + */ function getConfig() : array { return $this->config; } + /** + * Get the logger instance. + * + * @return Logger Instance of logger + */ function getLogger() : Logger { return $this->logger; diff --git a/src/Rclone/Rclone.php b/src/Rclone/Rclone.php index c459756..84dffba 100644 --- a/src/Rclone/Rclone.php +++ b/src/Rclone/Rclone.php @@ -9,7 +9,13 @@ use Symfony\Component\Process\Exception\ProcessFailedException; use Exception; - +/** + * Wrapper for the rclone command line utility + * + * Installation of rclone is required. + * Configuration of the mounts must be done before use. + * Tested using rclone v1.53.3-DEV + */ class Rclone { use LoggerAwareTrait; @@ -24,6 +30,14 @@ class Rclone protected string $version = ""; + /** + * Create a new instance + * + * Default it looks for "rclone" on the path. + * But the path can be configured to be absolute. + * + * @param string $rclonePath Relative or absolute path + */ function __construct(string $rclonePath = "rclone") { $this->rclonePath = $rclonePath; @@ -44,17 +58,35 @@ class Rclone } } + /** + * Get the rclone version + * + * @return string Version string + */ function getVersion(): string { return $this->version; } + /** + * Calculate the size of a mount/path + * + * @return int Size in bytes + */ function getSize(string $path): int { $output = $this->exec('size', ['--json', $path]); return (int)json_decode($output)->bytes; } + /** + * Copy from src to dest + * + * @param $src Source mount and path + * @param $dest Destination mount and path + * @param $bandwidth Bandwidth limit provided as string + * @return string Stdout from command + */ function copy(string $src, string $dest, string $bandwidth = null): string { $options = array(); diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 2da3a95..08d6474 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -6,8 +6,20 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; +/** + * Twig extension + * + * Additional formatters for templates + * + * @author Jens True + * @license https://opensource.org/licenses/gpl-license.php GNU Public License + * @link https://jcktrue.dk + */ class AppExtension extends AbstractExtension { + /** + * Extend the filters + */ public function getFilters() { return array(