ProfileFormWidget   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 9 4
A run() 0 4 1
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\organization\widgets;
14
15
use rhosocial\organization\Organization;
16
use rhosocial\organization\Profile;
17
use yii\base\InvalidConfigException;
18
use yii\base\Widget;
19
20
/**
21
 * @version 1.0
22
 * @author vistart <[email protected]>
23
 */
24
class ProfileFormWidget extends Widget
25
{
26
    /**
27
     * @var Organization 
28
     */
29
    public $organization;
30
    /**
31
     * @var Profile 
32
     */
33
    public $model;
34
35
    public function init()
36
    {
37
        if (is_null($this->model) || !($this->model instanceof Profile)) {
38
            if (!$this->organization) {
39
                throw new InvalidConfigException("Organization or Profile should either be valid.");
40
            }
41
            $this->model = $this->organization->createProfile(['scenario' => Profile::SCENARIO_UPDATE]);
42
        }
43
    }
44
45
    public function run()
46
    {
47
        return $this->render('profile-form', ['model' => $this->model]);
48
    }
49
}
50