diff --git a/composer.json b/composer.json
index d95c404..061359e 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
{
- "name": "gears/pdf",
+ "name": "ETSGlobal/pdf",
"description": "A PDF builder using HTML or DOCX templates.",
"homepage": "https://github.com/phpgearbox/pdf",
"keywords": ["pdf", "docx", "template", "builder", "converter"],
@@ -13,20 +13,20 @@
},
"require":
{
+ "php": "^7.0",
"gears/di": "*",
- "gears/string": "^0.6.0",
- "symfony/process": "2.*",
- "symfony/filesystem": "2.*",
+ "symfony/process": "2.*|3.*",
+ "symfony/filesystem": "2.*|3.*",
"jakoch/phantomjs-installer": "1.9.8"
},
"require-dev":
{
"codegyre/robo": "*",
- "phpunit/phpunit": "4.*",
+ "phpunit/phpunit": "^4.8|^5.6",
"guzzlehttp/guzzle": "4.*",
"sgh/pdfbox": "dev-master",
"google/apiclient": "1.*",
- "symfony/finder": "2.*"
+ "symfony/finder": "2.*|3.*"
},
"scripts":
{
diff --git a/src/Pdf.php b/src/Pdf.php
index c07a922..51077e3 100644
--- a/src/Pdf.php
+++ b/src/Pdf.php
@@ -13,7 +13,6 @@
use SplFileInfo;
use RuntimeException;
-use Gears\String as Str;
use Gears\Di\Container;
use Gears\Pdf\TempFile;
@@ -121,7 +120,7 @@ public function __construct($document, $config = [])
}
// Check for a HTML string
- elseif (Str::contains($document, 'DOCTYPE'))
+ elseif (mb_strpos($document, 'DOCTYPE') !== false)
{
// Again lets save a temp file
$this->document = $this->tempFile($document, 'html');
@@ -198,8 +197,7 @@ public function save($path = null)
}
$ext = $this->originalDocument->getExtension();
- $path = Str::s($this->originalDocument->getPathname());
- $path = $path->replace('.'.$ext, '.pdf');
+ $path = str_replace('.'.$ext, '.pdf', $this->originalDocument->getPathname());
}
// Save the pdf to the output path
diff --git a/src/Pdf/Docx/Backend.php b/src/Pdf/Docx/Backend.php
index 212c040..d0d39a0 100644
--- a/src/Pdf/Docx/Backend.php
+++ b/src/Pdf/Docx/Backend.php
@@ -13,7 +13,7 @@
use ZipArchive;
use RuntimeException;
-use Gears\String as Str;
+use Gears\String\Str;
use Gears\Di\Container;
use Gears\Pdf\TempFile;
use Gears\Pdf\Docx\SimpleXMLElement;
@@ -23,7 +23,7 @@
class Backend extends Container implements BackendInterface
{
/**
- * @var Gears\Pdf\TempFile DOCX document to use as the template for our PDF.
+ * @var TempFile DOCX document to use as the template for our PDF.
* Set as the first argument of the constructor of
* this class.
*/
@@ -293,7 +293,7 @@ public function cloneRow($search, $numberOfClones)
$xml = $this->documentXML->asXml();
- if (($tagPos = strpos($xml, $search)) === false)
+ if (($tagPos = mb_strpos($xml, $search)) === false)
{
throw new RuntimeException
(
@@ -304,7 +304,7 @@ public function cloneRow($search, $numberOfClones)
$rowStart = $this->findRowStart($xml, $tagPos);
$rowEnd = $this->findRowEnd($xml, $tagPos);
- $xmlRow = Str::slice($xml, $rowStart, $rowEnd);
+ $xmlRow = mb_substr($xml, $rowStart, $rowEnd);
// Check if there's a cell spanning multiple rows.
if (preg_match('##', $xmlRow))
@@ -322,7 +322,7 @@ public function cloneRow($search, $numberOfClones)
// If tmpXmlRow doesn't contain continue,
// this row is no longer part of the spanned row.
- $tmpXmlRow = Str::slice($xml, $extraRowStart, $extraRowEnd);
+ $tmpXmlRow = mb_substr($xml, $extraRowStart, $extraRowEnd);
if
(
!preg_match('##', $tmpXmlRow) &&
@@ -336,17 +336,17 @@ public function cloneRow($search, $numberOfClones)
$rowEnd = $extraRowEnd;
}
- $xmlRow = Str::slice($xml, $rowStart, $rowEnd);
+ $xmlRow = mb_substr($xml, $rowStart, $rowEnd);
}
- $result = Str::slice($xml, 0, $rowStart);
+ $result = mb_substr($xml, 0, $rowStart);
for ($i = 1; $i <= $numberOfClones; $i++)
{
$result .= preg_replace('/\$\{(.*?)\}/', '\${\\1_' . $i . '}', $xmlRow);
}
- $result .= Str::slice($xml, $rowEnd);
+ $result .= mb_substr($xml, $rowEnd);
$this->documentXML = $this->xml($result);
}
@@ -584,7 +584,7 @@ protected function setValueForPart($xml, $search, $replace, $limit)
$search = $this->normaliseStartTag($search);
// Make sure the replacement value is encoded correctly.
- $replace = htmlspecialchars(Str::toUTF8($replace));
+ $replace = htmlspecialchars(mb_convert_encoding($replace, 'UTF-8'));
// Do the search and replace
return $this->xml(preg_replace
@@ -665,13 +665,15 @@ protected function getStartAndEndNodes($xml, $blockname)
// Search for the block start and end tags
foreach ($xml->xpath('//w:t') as $node)
{
- if (Str::contains($node, $this->normaliseStartTag($blockname)))
+
+
+ if (mb_strpos($node, $this->normaliseStartTag($blockname)) !== false)
{
$startNode = $node;
continue;
}
- if (Str::contains($node, $this->normaliseEndTag($blockname)))
+ if (mb_strpos($node, $this->normaliseEndTag($blockname)) !== false)
{
$endNode = $node;
break;
diff --git a/src/Pdf/Docx/Converter/LibreOffice.php b/src/Pdf/Docx/Converter/LibreOffice.php
index b47c3cb..3bff944 100644
--- a/src/Pdf/Docx/Converter/LibreOffice.php
+++ b/src/Pdf/Docx/Converter/LibreOffice.php
@@ -13,7 +13,6 @@
use RuntimeException;
use Gears\Di\Container;
-use Gears\String as Str;
use Gears\Pdf\TempFile;
use Symfony\Component\Process\Process;
use Gears\Pdf\Contracts\DocxConverter;
diff --git a/src/Pdf/Docx/Converter/Unoconv.php b/src/Pdf/Docx/Converter/Unoconv.php
index 52ed185..9eb6946 100644
--- a/src/Pdf/Docx/Converter/Unoconv.php
+++ b/src/Pdf/Docx/Converter/Unoconv.php
@@ -13,7 +13,6 @@
use RuntimeException;
use Gears\Di\Container;
-use Gears\String as Str;
use Gears\Pdf\TempFile;
use Symfony\Component\Process\Process;
use Gears\Pdf\Contracts\DocxConverter;
@@ -132,7 +131,7 @@ public function convertDoc(TempFile $docx)
// NOTE: For some really odd reason the first time the command runs
// it does not complete successfully. The second time around it
// works fine. It has something to do with the homedir setup...
- if (Str::contains($error, 'Error: Unable to connect'))
+ if (mb_strpos($error, 'Error: Unable to connect') !== false)
{
$process->run();
diff --git a/src/Pdf/Html/Backend.php b/src/Pdf/Html/Backend.php
index d166059..0ee3ecc 100644
--- a/src/Pdf/Html/Backend.php
+++ b/src/Pdf/Html/Backend.php
@@ -13,7 +13,7 @@
use RuntimeException;
use Gears\Di\Container;
-use Gears\String as Str;
+use Gears\String\Str;
use Gears\Pdf\TempFile;
use Symfony\Component\Process\Process;
use Gears\Pdf\Contracts\Backend as BackendInterface;
@@ -21,7 +21,7 @@
class Backend extends Container implements BackendInterface
{
/**
- * @var Gears\Pdf\TempFile The document we will convert to PDF.
+ * @var TempFile The document we will convert to PDF.
*/
protected $document;
@@ -42,7 +42,7 @@ class Backend extends Container implements BackendInterface
protected $injectRunner;
/**
- * @var Symfony\Component\Process\Process
+ * @var Process
*/
protected $injectProcess;
@@ -133,11 +133,7 @@ public function generate()
{
$this->document->setContents
(
- Str::s($this->document->getContents())->replace
- (
- '',
- $this->printFramework.''
- )
+ str_replace('', $this->printFramework.'', $this->document->getContents())
);
}
diff --git a/tests/PdfGoogleTest.php.disabled b/tests/PdfGoogleTest.php.disabled
index 9c8cd28..8a319c6 100644
--- a/tests/PdfGoogleTest.php.disabled
+++ b/tests/PdfGoogleTest.php.disabled
@@ -11,7 +11,7 @@
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
-use Gears\String as Str;
+use Gears\String\Str;
use SGH\PdfBox\PdfBox;
class PdfGoogleTest extends PHPUnit_Framework_TestCase
diff --git a/tests/PdfLibreOfficeTest.php b/tests/PdfLibreOfficeTest.php
index c99cc7a..b8d2416 100644
--- a/tests/PdfLibreOfficeTest.php
+++ b/tests/PdfLibreOfficeTest.php
@@ -11,7 +11,7 @@
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
-use Gears\String as Str;
+use Gears\String\Str;
use SGH\PdfBox\PdfBox;
class PdfLibreOfficeTest extends PHPUnit_Framework_TestCase
diff --git a/tests/PdfPhantomJsTest.php b/tests/PdfPhantomJsTest.php
index cacb339..4094ff4 100644
--- a/tests/PdfPhantomJsTest.php
+++ b/tests/PdfPhantomJsTest.php
@@ -11,7 +11,7 @@
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
-use Gears\String as Str;
+use Gears\String\Str;
use SGH\PdfBox\PdfBox;
class PdfPhantomJsTest extends PHPUnit_Framework_TestCase
diff --git a/tests/PdfUnoconvTest.php b/tests/PdfUnoconvTest.php
index 8349d99..470d3cb 100644
--- a/tests/PdfUnoconvTest.php
+++ b/tests/PdfUnoconvTest.php
@@ -11,7 +11,7 @@
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
-use Gears\String as Str;
+use Gears\String\Str;
use SGH\PdfBox\PdfBox;
class PdfUnoconvTest extends PHPUnit_Framework_TestCase