Completed
Push — master ( af939e...465698 )
by Michael
13s
created

PedigreePicture::__construct()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 23
Code Lines 16

Duplication

Lines 3
Ratio 13.04 %

Importance

Changes 0
Metric Value
cc 6
eloc 16
nc 32
nop 2
dl 3
loc 23
rs 8.5906
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 26 and the first side effect is on line 21.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
/**
12
 * PedigreeBreadcrumb Class
13
 *
14
 * @copyright   {@link http://xoops.org/ XOOPS Project}
15
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
16
 * @author      lucio <[email protected]>
17
 * @package     Pedigree
18
 * @since       1.31
19
 *
20
 */
21
require_once __DIR__ . '/htmlinput.abstract.php';
22
23
/**
24
 * Class Picture
25
 */
26
class PedigreePicture extends PedigreeHtmlInputAbstract
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: getSearchString, searchField
Loading history...
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...
27
{
28
    /**
29
     * @param Field $parentObject
30
     * @param PedigreeAnimal $animalObject
31
     */
32
    public function __construct($parentObject, $animalObject)
33
    {
34
        $this->fieldnumber  = $parentObject->getId();
0 ignored issues
show
Bug introduced by
The property fieldnumber does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
35
        $this->fieldname    = $parentObject->fieldname;
0 ignored issues
show
Bug introduced by
The property fieldname does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property fieldname does not seem to exist in Field.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
36
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
0 ignored issues
show
Bug introduced by
The property value does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
        $this->defaultvalue = $parentObject->defaultvalue;
0 ignored issues
show
Bug introduced by
The property defaultvalue does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property defaultvalue does not seem to exist in Field.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
38
        $this->lookuptable  = $parentObject->hasLookup();
0 ignored issues
show
Bug introduced by
The property lookuptable does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
39
        if ($this->lookuptable) {
40
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber);
41
        }
42
        if ($parentObject->InAdvanced()) {
43
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
44
        }
45
        if ($parentObject->inPie()) {
46
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
47
        }
48 View Code Duplication
        if ('1' == $parentObject->viewinlist) {
0 ignored issues
show
Bug introduced by
The property viewinlist does not seem to exist in Field.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be included in listview', get_class($this));
50
        }
51
        if ('1' == $parentObject->hassearch) {
0 ignored issues
show
Bug introduced by
The property hassearch does not seem to exist in Field.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
52
            xoops_error('Search cannot be defined for userfield ' . $this->fieldnumber, get_class($this));
53
        }
54
    }
55
56
    /**
57
     * @return XoopsFormFile
58
     */
59
    public function editField()
60
    {
61
        $picturefield = new XoopsFormFile($this->fieldname, 'user' . $this->fieldnumber, 1024000);
62
        $picturefield->setExtra("size ='50'");
63
64
        return $picturefield;
65
    }
66
67
    /**
68
     * @param string $name
69
     *
70
     * @return XoopsFormFile
71
     */
72 View Code Duplication
    public function newField($name = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    {
74
        $picturefield = new XoopsFormFile($this->fieldname, $name . 'user' . $this->fieldnumber, 1024000);
75
        $picturefield->setExtra("size ='50'");
76
77
        return $picturefield;
78
    }
79
80
    /**
81
     * @return XoopsFormLabel
82
     */
83
    public function viewField()
84
    {
85
        $view = new XoopsFormLabel($this->fieldname, "<img src=\"assets/images/thumbnails/" . $this->value . "_400.jpeg\">");
86
87
        return $view;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function showField()
94
    {
95
        return "<img src=\"assets/images/thumbnails/" . $this->value . "_150.jpeg\">";
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function showValue()
102
    {
103
        return "<img src=\"assets/images/thumbnails/" . $this->value . "_400.jpeg\">";
104
    }
105
}
106