Completed
Pull Request — master (#6)
by Dima
24:36 queued 06:53
created

Gallery   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 9
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 4
A getImages() 0 11 3
A issetImages() 0 4 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: myslyvyi
5
 * Date: 05.01.2016
6
 * Time: 15:25
7
 */
8
9
namespace samsoncms\api;
10
11
class Gallery
12
{
13
    /** @var integer Table parent materialField identifier */
14
    protected $materialFieldId = null;
15
16
    /**
17
     * Constructor Gallery
18
     * @param integer $materialId material identifier
19
     * @param integer $fieldId field identifier
20
     */
21
    public function __construct($materialId, $fieldId)
22
    {
23
        $mf = null;
24
        if (is_int($materialId) && is_int($fieldId)) {
25
            if (dbQuery('materialfield')->cond('MaterialID', $materialId)->cond('FieldID', $fieldId)->first($mf)) {
0 ignored issues
show
Deprecated Code introduced by
The method samson\activerecord\dbQuery::cond() has been deprecated with message: @see self::where()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
26
                $this->materialFieldId = $mf->id;
27
            }
28
        }
29
    }
30
31
    /**
32
     * Get all images in gallery
33
     * @return array
34
     */
35
    public function getImages()
36
    {
37
        if ($this->issetImages()) {
38
            // array images from gallery
39
            $images = null;
40
            if (dbQuery('gallery')->cond('MaterialFieldID', $this->materialFieldId)->exec($images)) {
0 ignored issues
show
Deprecated Code introduced by
The method samson\activerecord\dbQuery::cond() has been deprecated with message: @see self::where()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
41
                return $images;
42
            }
43
        }
44
        return array();
45
    }
46
47
    /**
48
     * Check on empty gallery
49
     * @return boolean
50
     **/
51
    public function issetImages()
52
    {
53
        return (isset($this->materialFieldId)) ? true : false;
54
    }
55
}