Sample   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A afterFind() 0 21 3
1
<?php
2
class Sample extends AppModel {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
3
4
	public $belongsTo = array('Apple');
5
6
/**
7
 * afterFind
8
 *
9
 * @param array $results Results
10
 * @param bool $primary Primary
11
 * @return array
12
 */
13
	public function afterFind($results, $primary = false) {
14
		foreach ($results as &$result) {
15
			$apple = $this->Apple->find('first', array(
16
				'fields' => array(
17
					'Apple.id',
18
					'Apple.apple_id',
19
				),
20
				'contain' => array(
21
					'ParentApple' => array('fields' => array('id', 'name')),
22
				),
23
				'conditions' => array('Apple.id' => $result[$this->alias]['id']),
24
			));
25
26
			if ($apple) {
27
				$apple = $apple['Apple'] + $apple;
28
				unset($apple['Apple']);
29
			}
30
			$result[$this->alias]['Apple'] = $apple;
31
		}
32
		return $results;
33
	}
34
}
35