for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DataTypes;
use InvalidArgumentException;
/**
* @since 0.1
*
* @license GPL-2.0+
* @author Jeroen De Dauw < [email protected] >
* @author Thiemo Mättig
*/
class DataType {
* Identifier of this data type (also referred to as "property type").
* @var string
protected $typeId;
* Identifier for the type of the DataValue.
protected $dataValueType;
* @since 0.5
* @param string $typeId Identifier of this data type (also referred to as "property type").
* @param string $dataValueType Identifier for the type of the DataValue.
* @throws InvalidArgumentException
public function __construct( $typeId, $dataValueType ) {
if ( !is_string( $typeId ) || $typeId === '' ) {
throw new InvalidArgumentException( '$typeId must be a non-empty string' );
}
if ( !is_string( $dataValueType ) || $dataValueType === '' ) {
throw new InvalidArgumentException( '$dataValueType must be a non-empty string' );
$this->typeId = $typeId;
$this->dataValueType = $dataValueType;
* Returns the identifier of this data type (also referred to as "property type").
* @return string
public function getId() {
return $this->typeId;
* Returns the type of the DataValue used by this data type.
public function getDataValueType() {
return $this->dataValueType;
* @since 1.0
public function getMessageKey() {
return 'datatypes-type-' . $this->typeId;
* @return string[]
public function toArray() {
return array(
'dataValueType' => $this->dataValueType
);