Completed
Push — master ( 14d2bd...06e609 )
by mw
81:37 queued 59:24
created

includes/dataitems/SMW_DI_Blob.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @ingroup SMWDataItems
4
 */
5
6
/**
7
 * This class implements blob (long string) data items.
8
 *
9
 * @since 1.6
10
 *
11
 * @author Markus Krötzsch
12
 * @ingroup SMWDataItems
13
 */
14
class SMWDIBlob extends SMWDataItem {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
15
16
	/**
17
	 * Internal value.
18
	 * @var string
19
	 */
20
	protected $m_string;
21
22 202
	public function __construct( $string ) {
23 202
		$this->m_string = trim( $string );
24 202
	}
25
26 190
	public function getDIType() {
27 190
		return SMWDataItem::TYPE_BLOB;
28
	}
29
30 180
	public function getString() {
31 180
		return $this->m_string;
32
	}
33
34 10
	public function getSortKey() {
35 10
		return $this->m_string;
36
	}
37
38
	/**
39
	 * @see SMWDataItem::getSortKeyDataItem()
40
	 * @return SMWDataItem
41
	 */
42
	public function getSortKeyDataItem() {
43
		return $this;
44
	}
45
46 201
	public function getSerialization() {
47 201
		return $this->m_string;
48
	}
49
50
	/**
51
	 * Create a data item from the provided serialization string and type
52
	 * ID.
53
	 * @return SMWDIBlob
54
	 */
55 7
	public static function doUnserialize( $serialization ) {
56 7
		return new SMWDIBlob( $serialization );
57
	}
58
59 6
	public function equals( SMWDataItem $di ) {
60 6
		if ( !( $di instanceof SMWDIBlob ) ) {
61
			return false;
62
		}
63
64 6
		return $di->getString() === $this->m_string;
65
	}
66
}
67