Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
CheckDefault.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 class CheckDefault extends CheckData
8 {
9  protected $defaultName;
10  protected $defaultValue = '';
11  /**
12  * @var Doc
13  */
14  protected $doc;
15  /**
16  * @param array $data
17  * @param Doc $doc
18  * @return CheckDefault
19  */
20  function check(array $data, &$doc = null)
21  {
22  $this->defaultName = trim(strtolower($data[1]));
23  if (isset($data[2])) $this->defaultValue = trim($data[2]);
24  $this->doc = $doc;
25  $this->checkDefaultName();
26  $this->checkDefaultValue();
27  return $this;
28  }
29  /**
30  * check default name syntax
31  * @return void
32  */
33  protected function checkDefaultName()
34  {
35  if ($this->defaultName) {
36  if (!CheckAttr::checkAttrSyntax($this->defaultName)) {
37  $this->addError(ErrorCode::getError('DFLT0001', $this->defaultName, $this->doc->name));
38  }
39  } else {
40 
41  $this->addError(ErrorCode::getError('DFLT0002', $this->doc->name));
42  }
43  }
44  /**
45  * check default value if seems to be method
46  * @return void
47  */
48  protected function checkDefaultValue()
49  {
50  if (preg_match('/^[a-z_0-9]*::/i', $this->defaultValue)) {
51  $oParse = new parseFamilyMethod();
52  $strucFunc = $oParse->parse($this->defaultValue, true);
53  if ($err = $strucFunc->getError()) {
54 
55  $this->addError(ErrorCode::getError('DFLT0003', $this->defaultName, $this->defaultValue, $this->doc->name, $err));
56  }
57  }
58  }
59 }
static getError($code, $args=null)
Definition: ErrorCode.php:27
static checkAttrSyntax($attrid)
Definition: checkAttr.php:609
addError($msg)
Definition: CheckData.php:29
if($file) if($subject==""&&$file) if($subject=="") $err
check(array $data, &$doc=null)
$data
← centre documentaire © anakeen