Esempio n. 1
0
 public function sort(Comparator $comparator = null)
 {
     if (is_null($comparator)) {
         if (TypeUtil::isPrimitive($this->type)) {
             sort($this->elements);
         } elseif (TypeUtil::isObjectType($this->type)) {
             if (!TypeUtil::isClassComparable($this->type)) {
                 throw new ListNotSortableException("List of type " . $this->type . " is not sortable");
             }
             usort($this->elements, function ($a, $b) {
                 return $a->compareTo($b);
             });
         }
     } else {
         usort($this->elements, function ($a, $b) use($comparator) {
             return $comparator->compare($a, $b);
         });
     }
 }
Esempio n. 2
0
 function testObjectIsNotPrimitive()
 {
     $this->assertFalse(TypeUtil::isPrimitive("IsPrimitiveTypeTest"));
 }