From 7498cf4a994605abe1e728db9fced50a6d4924ce Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Sun, 25 Feb 2018 15:09:23 +0100 Subject: [PATCH] Added some convenience methods --- Latex/Base/Standalone.php | 2 -- Latex/LatexBase.php | 51 ++++++++++++++++++++++++++------ Latex/LatexBaseInterface.php | 38 +++++++++++++++++++++--- Resources/doc/base/Article.md | 6 +++- Resources/doc/base/Book.md | 6 +++- Resources/doc/base/Letter.md | 6 +++- Resources/doc/base/Standalone.md | 4 +++ 7 files changed, 95 insertions(+), 18 deletions(-) diff --git a/Latex/Base/Standalone.php b/Latex/Base/Standalone.php index 0a3542e..b9fe9b5 100644 --- a/Latex/Base/Standalone.php +++ b/Latex/Base/Standalone.php @@ -10,8 +10,6 @@ class Standalone extends LatexBase * Article constructor, sets defaults * * @param string $filename - * - * @throws \BobV\LatexBundle\Exception\LatexException */ public function __construct($filename) { // Define standard values diff --git a/Latex/LatexBase.php b/Latex/LatexBase.php index d9a5724..0d6df56 100644 --- a/Latex/LatexBase.php +++ b/Latex/LatexBase.php @@ -1,4 +1,5 @@ dependencies; } /** * @param $dependency * - * @return LatexInterface $this + * @return LatexBaseInterface $this */ - public function addDependency($dependency){ + public function addDependency($dependency) + { $this->dependencies[] = $dependency; return $this; } + /** + * To add multiple dependencies locations + * + * @param $dependencies + * + * @return LatexBaseInterface + */ + public function addDependencies($dependencies) + { + foreach ($dependencies as $dependency) { + $this->addDependency($dependency); + } + + return $this; + } + /** * Add an package to include * * @param $package * @param $options * - * @return LatexInterface $this + * @return LatexBaseInterface $this */ public function addPackage($package, $options = '') { @@ -146,9 +163,25 @@ public function addPackage($package, $options = '') $this->params['packages'][] = array( 'p' => $package, - 'o' => $options + 'o' => $options, ); return $this; } + + /** + * Add multiple packages to include (without options) + * + * @param $packages + * + * @return mixed + */ + public function addPackages($packages) + { + foreach ($packages as $package) { + $this->addPackage($package); + } + + return $this; + } } diff --git a/Latex/LatexBaseInterface.php b/Latex/LatexBaseInterface.php index 4278dc3..7cfeb06 100644 --- a/Latex/LatexBaseInterface.php +++ b/Latex/LatexBaseInterface.php @@ -1,4 +1,5 @@