00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00018 abstract class ComplexPrimitive extends RangedPrimitive
00019 {
00020 private $single = null;
00021
00022 public function __construct($name)
00023 {
00024 $this->single = new Ternary(null);
00025 parent::__construct($name);
00026 }
00027
00031 public function getState()
00032 {
00033 return $this->single;
00034 }
00035
00039 public function setState(Ternary $ternary)
00040 {
00041 $this->single->setValue($ternary->getValue());
00042
00043 return $this;
00044 }
00045
00049 public function setSingle()
00050 {
00051 $this->single->setTrue();
00052
00053 return $this;
00054 }
00055
00059 public function setComplex()
00060 {
00061 $this->single->setFalse();
00062
00063 return $this;
00064 }
00065
00069 public function setAnyState()
00070 {
00071 $this->single->setNull();
00072
00073 return $this;
00074 }
00075
00076
00077 abstract protected function importSingle($scope);
00078 abstract protected function importMarried($scope);
00079
00080 public function import($scope)
00081 {
00082 if (!$result = parent::import($scope))
00083 return $result;
00084
00085 if ($this->single->isTrue())
00086 return $this->importSingle($scope);
00087 elseif ($this->single->isFalse())
00088 return $this->importMarried($scope);
00089 else {
00090 if (!$this->importMarried($scope))
00091 return $this->importSingle($scope);
00092
00093 return $this->imported = true;
00094 }
00095
00096 Assert::isUnreachable();
00097 }
00098 }
00099 ?>