Completed
Push — master ( cd12ec...fb91d6 )
by Gino
03:28
created

TemplatesUserPdf::renderFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: TemplatesUserPdf.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class TemplatesUserPdf.
27
 */
28
class TemplatesUserPdf extends TDMCreateFile
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
29
{
30
    /*
31
    * @var string
32
    */
33
    private $tdmcfile = null;
34
35
    /*
36
    *  @public function constructor
37
    *  @param null
38
    */
39
    /**
40
     *
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
        $this->tdmcfile = TDMCreateFile::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreateFile::getInstance() of type object<TDMCreateFile> is incompatible with the declared type string of property $tdmcfile.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
    }
47
48
    /*
49
    *  @static function &getInstance
50
    *  @param null
51
    */
52
    /**
53
     * @return TemplatesUserPdf
54
     */
55
    public static function &getInstance()
56
    {
57
        static $instance = false;
58
        if (!$instance) {
59
            $instance = new self();
60
        }
61
62
        return $instance;
63
    }
64
65
    /*
66
    *  @public function write
67
    *  @param string $module
68
    *  @param string $table
69
    *  @param string $filename
70
    */
71
    /**
72
     * @param $module
73
     * @param $table
74
     */
75
    public function write($module)
76
    {
77
        $this->setModule($module);
78
    }
79
80
    /*
81
    *  @private function getTemplatesUserPdfBody
82
    *  @param null
83
84
    */
85
    /**
86
     * @param null
87
     *
88
     * @return string
89
     */
90
    private function getTemplatesUserPdfBody()
91
    {
92
        $ret = <<<EOT
93
<div><{\$pdfoutput}></div>
94
EOT;
95
96
        return $ret;
97
    }
98
99
    /*
100
    *  @public function renderFile
101
    *  @param string $filename
102
    */
103
    /**
104
     * @param $filename
105
     *
106
     * @return bool|string
107
     */
108
    public function renderFile($filename)
109
    {
110
        $module = $this->getModule();
111
        $moduleDirname = $module->getVar('mod_dirname');
112
        $content = $this->getTemplatesUserPdfBody();
113
        //
114
        $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
0 ignored issues
show
Bug introduced by
The method create cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
115
116
        return $this->tdmcfile->renderFile();
0 ignored issues
show
Bug introduced by
The method renderFile cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
117
    }
118
}
119