1616use GuzzleHttp \RequestOptions ;
1717use TxTextControl \ReportingCloud \Exception \InvalidArgumentException ;
1818use TxTextControl \ReportingCloud \PropertyMap ;
19+
20+ use TxTextControl \ReportingCloud \Validator \DocumentExtension as DocumentExtensionValidator ;
1921use TxTextControl \ReportingCloud \Validator \ImageFormats as ImageFormatsValidator ;
2022use TxTextControl \ReportingCloud \Validator \Page as PageValidator ;
2123use TxTextControl \ReportingCloud \Validator \ReturnFormats as ReturnFormatsValidator ;
24+ use TxTextControl \ReportingCloud \Validator \TemplateExtension as TemplateExtensionValidator ;
2225use TxTextControl \ReportingCloud \Validator \TemplateName as TemplateNameValidator ;
2326use TxTextControl \ReportingCloud \Validator \Timestamp as TimeStampValidator ;
2427use TxTextControl \ReportingCloud \Validator \ZoomFactor as ZoomFactorValidator ;
@@ -332,6 +335,16 @@ public function uploadTemplate($templateFilename)
332335 {
333336 $ ret = false ;
334337
338+ $ templateExtensionValidator = new TemplateExtensionValidator ();
339+
340+ if (!$ templateExtensionValidator ->isValid ($ templateFilename )) {
341+ throw new InvalidArgumentException (
342+ sprintf ("'templateFilename' %s does not have a supported file extension " ,
343+ $ templateFilename
344+ )
345+ );
346+ }
347+
335348 if (!is_readable ($ templateFilename )) {
336349 throw new InvalidArgumentException (
337350 sprintf ("'templateFilename' %s cannot be read from the local file system " ,
@@ -386,7 +399,16 @@ public function convertDocument($documentFilename, $returnFormat)
386399 {
387400 $ ret = null ;
388401
389- $ returnFormatsValidator = new ReturnFormatsValidator ();
402+ $ documentExtensionValidator = new DocumentExtensionValidator ();
403+ $ returnFormatsValidator = new ReturnFormatsValidator ();
404+
405+ if (!$ documentExtensionValidator ->isValid ($ documentFilename )) {
406+ throw new InvalidArgumentException (
407+ sprintf ("'documentFilename' %s does not have a supported file extension " ,
408+ $ documentFilename
409+ )
410+ );
411+ }
390412
391413 if (!is_readable ($ documentFilename )) {
392414 throw new InvalidArgumentException (
@@ -456,9 +478,10 @@ public function mergeDocument($mergeData, $returnFormat, $templateName = null, $
456478 {
457479 $ ret = null ;
458480
459- $ returnFormatsValidator = new ReturnFormatsValidator ();
460- $ templateNameValidator = new TemplateNameValidator ();
461- $ timestampValidator = new TimestampValidator ();
481+ $ returnFormatsValidator = new ReturnFormatsValidator ();
482+ $ templateExtensionValidator = new TemplateExtensionValidator ();
483+ $ templateNameValidator = new TemplateNameValidator ();
484+ $ timestampValidator = new TimestampValidator ();
462485
463486 if (!$ returnFormatsValidator ->isValid ($ returnFormat )) {
464487 throw new InvalidArgumentException (
@@ -478,6 +501,13 @@ public function mergeDocument($mergeData, $returnFormat, $templateName = null, $
478501 }
479502
480503 if (null !== $ templateFilename ) {
504+ if (!$ templateExtensionValidator ->isValid ($ templateFilename )) {
505+ throw new InvalidArgumentException (
506+ sprintf ("'templateFilename' %s does not have a supported file extension " ,
507+ $ templateFilename
508+ )
509+ );
510+ }
481511 if (!is_readable ($ templateFilename )) {
482512 throw new InvalidArgumentException (
483513 sprintf ("'templateFilename' %s cannot be read from the local file system " ,
0 commit comments