Esempio n. 1
0
File: Html.php Progetto: seytar/psx
 protected function getValueDescription(PropertyInterface $type)
 {
     if ($type instanceof Property\ComplexType) {
         $span = '<span class="psx-property-type psx-property-type-complex"><a href="#psx-type-' . $type->getId() . '">' . $type->getName() . '</a></span>';
         return [$span, null];
     } elseif ($type instanceof Property\ArrayType) {
         $constraints = array();
         $min = $type->getMinLength();
         if ($min !== null) {
             $constraints['minimum'] = '<span class="psx-constraint-minimum">' . $min . '</span>';
         }
         $max = $type->getMaxLength();
         if ($max !== null) {
             $constraints['maximum'] = '<span class="psx-constraint-maximum">' . $max . '</span>';
         }
         $constraint = $this->constraintToString($constraints);
         $property = $this->getValueDescription($type->getPrototype());
         $span = '<span class="psx-property-type psx-property-type-array">Array&lt;' . $property[0] . '&gt;</span>';
         return [$span, $constraint];
     } elseif ($type instanceof Property\ChoiceType) {
         $choice = array();
         $properties = $type->getProperties();
         foreach ($properties as $prop) {
             $property = $this->getValueDescription($prop);
             $choice[] = $property[0];
         }
         $span = '<span class="psx-property-type psx-property-type-choice">' . implode('|', $choice) . '</span>';
         return [$span, null];
     } elseif ($type instanceof PropertySimpleAbstract) {
         $typeName = ucfirst($type->getTypeName());
         $constraints = array();
         if ($type->getPattern() !== null) {
             $constraints['pattern'] = '<span class="psx-constraint-pattern">' . $type->getPattern() . '</span>';
         }
         if ($type->getEnumeration() !== null) {
             $enumeration = '<ul class="psx-property-enumeration">';
             foreach ($type->getEnumeration() as $enum) {
                 $enumeration .= '<li><span class="psx-constraint-enumeration-value">' . $enum . '</span></li>';
             }
             $enumeration .= '</ul>';
             $constraints['enumeration'] = '<span class="psx-constraint-enumeration">' . $enumeration . '</span>';
         }
         if ($type instanceof Property\DecimalType) {
             $min = $type->getMin();
             if ($min !== null) {
                 $constraints['minimum'] = '<span class="psx-constraint-minimum">' . $min . '</span>';
             }
             $max = $type->getMax();
             if ($max !== null) {
                 $constraints['maximum'] = '<span class="psx-constraint-maximum">' . $max . '</span>';
             }
         } elseif ($type instanceof Property\StringType) {
             $min = $type->getMinLength();
             if ($min !== null) {
                 $constraints['minimum'] = '<span class="psx-constraint-minimum">' . $min . '</span>';
             }
             $max = $type->getMaxLength();
             if ($max !== null) {
                 $constraints['maximum'] = '<span class="psx-constraint-maximum">' . $max . '</span>';
             }
         }
         $constraint = $this->constraintToString($constraints);
         $cssClass = 'psx-property-type-' . strtolower($typeName);
         if ($type instanceof Property\DateType) {
             $typeName = '<a href="http://tools.ietf.org/html/rfc3339#section-5.6" title="RFC3339">Date</a>';
         } elseif ($type instanceof Property\DateTimeType) {
             $typeName = '<a href="http://tools.ietf.org/html/rfc3339#section-5.6" title="RFC3339">DateTime</a>';
         } elseif ($type instanceof Property\TimeType) {
             $typeName = '<a href="http://tools.ietf.org/html/rfc3339#section-5.6" title="RFC3339">Time</a>';
         } elseif ($type instanceof Property\DurationType) {
             $typeName = '<span title="ISO 8601">Duration</span>';
         }
         $span = '<span class="psx-property-type ' . $cssClass . '">' . $typeName . '</span>';
         return [$span, $constraint];
     }
 }
Esempio n. 2
0
 protected function getPropertyTypeName(PropertyInterface $type)
 {
     switch ($type->getTypeName()) {
         case 'float':
             return 'number';
         case 'integer':
             return 'integer';
         case 'boolean':
             return 'boolean';
         default:
             return 'string';
     }
 }
Esempio n. 3
0
File: Xsd.php Progetto: seytar/psx
 protected function getBasicType(PropertyInterface $type, $withNamespace = false)
 {
     return ($withNamespace ? 'xs:' : '') . $type->getTypeName();
 }