Passed
Pull Request — master (#81)
by Michael
02:55
created

Profile   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 6
dl 0
loc 23
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A init() 0 5 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Yogurt;
6
7
/**
8
 * Extended User Profile
9
 *
10
 * You may not change or alter any portion of this comment or credits
11
 * of supporting developers from this source code or any supporting source code
12
 * which is considered copyrighted (c) material of the original comment or credit authors.
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 *
17
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
18
 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
19
 * @package             profile
20
 * @since               2.3.0
21
 * @author              Jan Pedersen
22
 * @author              Taiwen Jiang <[email protected]>
23
 */
24
25
// defined('XOOPS_ROOT_PATH') || exit("XOOPS root path not defined");
26
27
/**
28
 * @package             kernel
29
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
30
 */
31
class Profile extends \XoopsObject
32
{
33
    /**
34
     * @param $fields
35
     */
36
37
    public function __construct($fields)
38
    {
39
        $this->initVar('profile_id', \XOBJ_DTYPE_INT, null, true);
40
41
        $this->init($fields);
42
    }
43
44
    /**
45
     * Initiate variables
46
     * @param array $fields field information array of {@link XoopsField} objects
47
     */
48
49
    public function init($fields)
50
    {
51
        if (\is_array($fields) && \count($fields) > 0) {
52
            foreach (\array_keys($fields) as $key) {
53
                $this->initVar($key, $fields[$key]->getVar('field_valuetype'), $fields[$key]->getVar('field_default', 'n'), $fields[$key]->getVar('field_required'), $fields[$key]->getVar('field_maxlength'));
54
            }
55
        }
56
    }
57
}
58