コード例 #1
0
 /**
  * Create a sort key
  *
  * @return string
  */
 public function getSortKey()
 {
     $key = strtoupper($this->letters);
     if ($this->digits) {
         if ($key) {
             $key .= ' ';
         }
         $key .= strlen((int) $this->digits);
         $key .= $this->digits;
     }
     $key .= $this->decimal;
     if ($this->suffix) {
         if ($key) {
             $key .= ' ';
             if (ctype_alpha($this->suffix[0])) {
                 $key .= '_';
             }
         }
         $key .= MetadataUtils::createSortableString($this->suffix);
     }
     if ($this->cutter) {
         foreach (preg_split('/[A-Za-z]\\d+/', $this->cutter) as $part) {
             if ($key) {
                 $key .= ' ';
             }
             $key .= MetadataUtils::createSortableString($part);
         }
     }
     return $key;
 }
コード例 #2
0
 /**
  * Tests for createSortableString
  *
  * @return void
  */
 public function testCreateSortableString()
 {
     $this->assertEquals('A 3123', MetadataUtils::createSortableString('A 123'));
     $this->assertEquals('A 3123 18 ABC', MetadataUtils::createSortableString('A 123 8 abc'));
     $this->assertEquals('A 11 12', MetadataUtils::createSortableString('A  1   2'));
 }