Passed
Branch master (48d769)
by Michael
02:30
created

Picture::__construct()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
nc 32
nop 2
dl 0
loc 21
rs 8.7624
c 0
b 0
f 0
1
<?php namespace XoopsModules\Pedigree;
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
 * Pedigree\Breadcrumb Class
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      lucio <[email protected]>
18
 * @package     Pedigree
19
 * @since       1.31
20
 *
21
 */
22
use XoopsModules\Pedigree;
23
24
25
/**
26
 * Class Picture
27
 */
28
class Picture extends Pedigree\HtmlInputAbstract
29
{
30
    /**
31
     * @param Field          $parentObject
32
     * @param Pedigree\Animal $animalObject
33
     */
34
    public function __construct($parentObject, $animalObject)
35
    {
36
        $this->fieldnumber  = $parentObject->getId();
0 ignored issues
show
Bug Best Practice introduced by
The property fieldnumber does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
37
        $this->fieldname    = $parentObject->fieldname;
0 ignored issues
show
Bug Best Practice introduced by
The property fieldname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultvalue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40
        $this->lookuptable  = $parentObject->hasLookup();
0 ignored issues
show
Bug Best Practice introduced by
The property lookuptable does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
        if ($this->lookuptable) {
42
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber);
0 ignored issues
show
Bug introduced by
The function xoops_error was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
            /** @scrutinizer ignore-call */ 
43
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber);
Loading history...
43
        }
44
        if ($parentObject->inAdvanced()) {
45
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
46
        }
47
        if ($parentObject->inPie()) {
48
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
49
        }
50
        if ('1' == $parentObject->viewinlist) {
0 ignored issues
show
Bug introduced by
The property viewinlist does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
51
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be included in listview', get_class($this));
52
        }
53
        if ('1' == $parentObject->hassearch) {
0 ignored issues
show
Bug introduced by
The property hassearch does not seem to exist on XoopsModules\Pedigree\Field.
Loading history...
54
            xoops_error('Search cannot be defined for userfield ' . $this->fieldnumber, get_class($this));
55
        }
56
    }
57
58
    /**
59
     * @return \XoopsFormFile
60
     */
61
    public function editField()
62
    {
63
        $picturefield = new \XoopsFormFile($this->fieldname, 'user' . $this->fieldnumber, 1024000);
0 ignored issues
show
Bug introduced by
The type XoopsFormFile was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
64
        $picturefield->setExtra("size ='50'");
65
66
        return $picturefield;
67
    }
68
69
    /**
70
     * @param string $name
71
     *
72
     * @return \XoopsFormFile
73
     */
74
    public function newField($name = '')
75
    {
76
        $picturefield = new \XoopsFormFile($this->fieldname, $name . 'user' . $this->fieldnumber, 1024000);
77
        $picturefield->setExtra("size ='50'");
78
79
        return $picturefield;
80
    }
81
82
    /**
83
     * @return \XoopsFormLabel
84
     */
85
    public function viewField()
86
    {
87
        $view = new \XoopsFormLabel($this->fieldname, '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">');
0 ignored issues
show
Bug introduced by
The type XoopsFormLabel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
88
89
        return $view;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function showField()
96
    {
97
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_150.jpeg">';
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function showValue()
104
    {
105
        return '<img src="' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $this->value . '_400.jpeg">';
106
    }
107
}
108