Skip to content

Commit

Permalink
Minor cleanup in SMWDataItem
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Jul 22, 2015
1 parent 94de1f3 commit 73ca98c
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions includes/dataitems/SMW_DataItem.php
@@ -1,11 +1,4 @@
<?php
/**
* File holding abstract class SMWDataItem, the base for all dataitems in SMW.
*
* @author Markus Kr枚tzsch
*
* @ingroup SMWDataItems
*/

/**
* This group contains all parts of SMW that relate to the processing of dataitems
Expand Down Expand Up @@ -89,7 +82,7 @@ abstract public function getDIType();
* sortkey that is assigned to them as a property value. When pages are
* sorted, this data should be used if possible.
*
* @return float or string
* @return float|string
*/
abstract public function getSortKey();

Expand All @@ -113,12 +106,13 @@ abstract public function equals( SMWDataItem $di );
* @return SMWDataItem
*/
public function getSortKeyDataItem() {
$sortkey = $this->getSortKey();
if ( is_numeric( $sortkey ) ) {
return new SMWDINumber( $sortkey );
} else {
return new SMWDIBlob( $sortkey );
$sortKey = $this->getSortKey();

if ( is_numeric( $sortKey ) ) {
return new SMWDINumber( $sortKey );
}

return new SMWDIBlob( $sortKey );
}

/**
Expand Down Expand Up @@ -155,7 +149,6 @@ public function __toString() {
*
* @param $diType integer dataitem ID
* @param $serialization string
* @param $typeid string SMW type ID (optional)
*
* @return SMWDataItem
*/
Expand All @@ -176,27 +169,27 @@ public static function newFromSerialization( $diType, $serialization ) {
public static function getDataItemClassNameForId( $diType ) {
switch ( $diType ) {
case self::TYPE_NUMBER:
return 'SMWDINumber';
return 'SMWDINumber';
case self::TYPE_BLOB:
return 'SMWDIBlob';
return 'SMWDIBlob';
case self::TYPE_BOOLEAN:
return 'SMWDIBoolean';
return 'SMWDIBoolean';
case self::TYPE_URI:
return 'SMWDIUri';
return 'SMWDIUri';
case self::TYPE_TIME:
return 'SMWDITime';
return 'SMWDITime';
case self::TYPE_GEO:
return 'SMWDIGeoCoord';
return 'SMWDIGeoCoord';
case self::TYPE_CONTAINER:
return 'SMWDIContainer';
return 'SMWDIContainer';
case self::TYPE_WIKIPAGE:
return 'SMWDIWikiPage';
return 'SMWDIWikiPage';
case self::TYPE_CONCEPT:
return 'SMWDIConcept';
return 'SMWDIConcept';
case self::TYPE_PROPERTY:
return 'SMWDIProperty';
return 'SMWDIProperty';
case self::TYPE_ERROR:
return 'SMWDIError';
return 'SMWDIError';
case self::TYPE_NOTYPE: default:
throw new InvalidArgumentException( "The value \"$diType\" is not a valid dataitem ID." );
}
Expand Down

0 comments on commit 73ca98c

Please sign in to comment.