-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathField.php
54 lines (44 loc) · 1.21 KB
/
Field.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Created by JetBrains PhpStorm.
* User: Kathy
* Date: 01/08/14
*/
namespace Foundation;
class Field {
/** @var \ReflectionClass */
private $refClass;
/** @var \ReflectionProperty */
private $property;
/** @var boolean */
private $isKey;
public function __constructor(\ReflectionClass $ref, \ReflectionProperty $property){
$this->refClass = $ref;
$this->property = $property;
}
/**
* Has the class in annotation this property as key?
*
* @return boolean
*/
public function isKey(){
if ($this->isKey === null){
foreach ($this->getAnnotationClass()->getAll('key') as $key){
if ($key == $this->property->getName()){
return true;
}
}
}
return $this->isKey;
}
/**
* @return \Phalcon\Annotations\Collection
*/
private function getAnnotationClass(){
$reader = new \Phalcon\Annotations\Reader();
$parsing = $reader->parse($this->refClass->getName());
//Create the reflection
$annotations = new \Phalcon\Annotations\Reflection($parsing);
return $annotations->getClassAnnotations();
}
}