Completed
Push — master ( 84afd6...650043 )
by Evstati
14s
created

Kohana_Jam_Field_Polymorphic   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 40
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 11 2
A initialize() 0 6 1
1
<?php defined('SYSPATH') OR die('No direct script access.');
2
/**
3
 * Handles polymorphic columns
4
 *
5
 * A polymorphic column is typically a string that specifies
6
 * the model to use for the row.
7
 *
8
 * @package    Jam
9
 * @category   Fields
10
 * @author     Jonathan Geiger
11
 * @copyright  (c) 2010-2011 Jonathan Geiger
12
 * @license    http://www.opensource.org/licenses/isc-license.txt
13
 */
14
abstract class Kohana_Jam_Field_Polymorphic extends Jam_Field_String {
15
16
	/**
17
	 * @var  boolean  this is a polymorphic field
18
	 */
19
	public $polymorphic = TRUE;
20
21
	/**
22
	 * Sets the default for the field to the model.
23
	 *
24
	 * @param   string  $model
0 ignored issues
show
Bug introduced by
There is no parameter named $model. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
25
	 * @param   string  $column
0 ignored issues
show
Bug introduced by
There is no parameter named $column. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
26
	 * @return  void
27
	 */
28 5
	public function initialize(Jam_Meta $meta, $name)
29
	{
30 5
		parent::initialize($meta, $name);
31
32 5
		$this->default = $this->model;
33 5
	}
34
35
	/**
36
	 * Casts to a string, preserving NULLs along the way.
37
	 *
38
	 * @param   mixed   $value
39
	 * @return  string
40
	 */
41 6
	public function set(Jam_Validated $model, $value, $is_changed)
42
	{
43 6
		list($value, $return) = $this->_default($model, $value);
44
45 6
		if ( ! $return)
46
		{
47 6
			$value = (string) $value;
48
		}
49
50 6
		return $value;
51
	}
52
53
} // End Kohana_Jam_Field_Polymorphic
54