AppUiObject::__call()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
rs 9.9332
cc 3
nc 3
nop 2
1
<?php
2
3
// -------------------------------------------------------------------------
4
// OVIDENTIA http://www.ovidentia.org
5
// Ovidentia is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2, or (at your option)
8
// any later version.
9
//
10
// This program is distributed in the hope that it will be useful, but
11
// WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18
// USA.
19
// -------------------------------------------------------------------------
20
/**
21
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
22
 * @copyright Copyright (c) 2022 by SI4YOU ({@link https://www.siforyou.com})
23
 */
24
namespace Capwelton\LibApp;
25
26
use Capwelton\Widgets\Widgets\Abstracts\WidgetCanvas;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widgets\Abstracts\WidgetCanvas 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...
27
use Capwelton\Widgets\Widgets\Abstracts\WidgetItem;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widgets\Abstracts\WidgetItem 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...
28
use Capwelton\Widgets\Widgets\Interfaces\WidgetDisplayableInterface;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widget...getDisplayableInterface 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...
29
use Capwelton\LibApp\Func_App;
30
31
/**
32
 * The AppUiObject class is used to simulate multiple inheritance from
33
 * both a AppObject and a WidgetItem
34
 * Typically to simulate inheritance from a WidgetVBoxLayout for example,
35
 * the constructor of the class will be defined as follow:
36
 * <pre>
37
 * public function __construct($app, $id = null)
38
 * {
39
 * parent::__construct($app);
40
 * // We simulate inheritance from WidgetVBoxLayout.
41
 * $this->setInheritedItem(bab_Functionality::get('Widgets')->VBoxLayout($id));
42
 * }
43
 * </pre>
44
 */
45
class AppUiObject extends AppObject implements WidgetDisplayableInterface
46
{
47
    
48
    /**
49
     * @var WidgetItem $item
50
     */
51
    protected $item = null;
52
    
53
    /**
54
     * @param Func_App $app
55
     */
56
    public function __construct(Func_App $app)
57
    {
58
        parent::__construct($app);
59
    }
60
    
61
    /**
62
     * Sets the item from which we will 'inherit'.
63
     *
64
     * @param WidgetItem $item
65
     * @return $this
66
     */
67
    public function setInheritedItem($item)
68
    {
69
        $this->item = $item;
70
        return $this;
71
    }
72
    
73
    /**
74
     * @ignore
75
     */
76
    public function __call($name, $arguments)
77
    {
78
        // We delegate all undefined methods to the $item object.
79
        if(isset($this->item)){
80
            $returnedValue = call_user_func_array(array(
81
                $this->item,
82
                $name
83
            ), $arguments);
84
            if($returnedValue === $this->item){
85
                $returnedValue = $this;
86
            }
87
            return $returnedValue;
88
        }
89
        else{
90
            trigger_error('the method ' . $name . ' does not exists on ' . get_class($this) . ' and there is no widget defined with the setInheritedItem method');
91
        }
92
    }
93
    
94
    /**
95
     * @param WidgetCanvas $canvas
96
     * @ignore
97
     */
98
    public function display(WidgetCanvas $canvas)
99
    {
100
        return $this->item->display($canvas);
101
    }
102
}