Foreign   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A hasField() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Storage package
5
 *
6
 * (c) Michal Wachowski <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Moss\Storage\Model\Definition\Index;
13
14
use Moss\Storage\Model\Definition\DefinitionException;
15
16
/**
17
 * Foreign defines foreign key in model
18
 *
19
 * @author  Michal Wachowski <[email protected]>
20
 * @package Moss\Storage
21
 */
22
class Foreign extends Index
23
{
24
    protected $table;
25
26
    /**
27
     * Constructor
28
     *
29
     * @param string $name
30
     * @param array  $fields
31
     * @param string $table
32
     *
33
     * @throws DefinitionException
34
     */
35
    public function __construct($name, array $fields, $table)
36
    {
37
        $this->name = $name;
38
        $this->type = 'foreign';
39
40
        $this->assertFields($fields);
41
42
        $this->fields = $fields;
43
44
        $this->table = $table;
45
    }
46
47
    /**
48
     * Checks if index uses field (unmapped)
49
     * Returns true if it does
50
     *
51
     * @param string $field
52
     *
53
     * @return bool
54
     */
55
    public function hasField($field)
56
    {
57
        return isset($this->fields[$field]);
58
    }
59
}
60