Completed
Push — master ( 484b1a...998a69 )
by Jeroen De
03:30
created

SemanticMaps/src/SM_GeoPolygonsValue.php (1 issue)

Labels
Severity

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
/**
4
 * Implementation of datavalues that are geographic shapes.
5
 *
6
 * @file SM_GeoPolgonValue.php
7
 * @ingroup SemanticMaps
8
 * @ingroup SMWDataValues
9
 *
10
 * @author Nischay Nahata
11
 */
12
class SMGeoPolygonsValue extends SMWDataValue {
13
14
	/**
15
	 * @see SMWDataValue::setDataItem()
16
	 *
17
	 * @param $dataitem SMWDataItem
18
	 *
19
	 * @return boolean
20
	 */
21
	protected function loadDataItem( SMWDataItem $dataItem ) {
22
		if ( $dataItem instanceof SMWDIBlob ) {
0 ignored issues
show
The class SMWDIBlob does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
23
			$this->m_dataitem = $dataItem;
24
			return true;
25
		}
26
27
		return false;
28
	}
29
30
	/**
31
	 * NOTE: Do param validation.
32
	 * TODO: Stores as a Blob, use better data structure
33
	 * @see SMWDataValue::parseUserValue
34
	 *
35
	 * @since 2.0
36
	 */
37
	protected function parseUserValue( $value ) {
38
		if ( $value === '' ) {
39
			$this->addError( wfMessage( 'smw_emptystring' )->inContentLanguage()->text() );
40
		}
41
		$polyHandler = new PolygonHandler ( $value );
42
		foreach( $polyHandler->getValidationErrors() as $errMsg ) {
43
			$this->addError( $errMsg );
44
		}
45
		$this->m_dataitem = new SMWDIBlob( $value, $this->m_typeid );
46
	}
47
48
	/**
49
	 * @see SMWDataValue::getShortWikiText
50
	 *
51
	 * @since 2.0
52
	 */
53
	public function getShortWikiText( $linked = null ) {
54
		if ( $this->isValid() ) {
55
			return $this->m_dataitem->getString();
56
		} else {
57
			return $this->getErrorText();
58
		}
59
	}
60
61
	/**
62
	 * @see SMWDataValue::getShortHTMLText
63
	 *
64
	 * @since 2.0
65
	 */
66
	public function getShortHTMLText( $linker = null ) {
67
		return $this->getShortWikiText( $linker );
68
	}
69
70
	/**
71
	 * @see SMWDataValue::getLongWikiText
72
	 *
73
	 * @since 2.0
74
	 */
75
	public function getLongWikiText( $linker = null ) {
76
		return $this->getShortWikiText( $linker );
77
	}
78
79
	/**
80
	 * @see SMWDataValue::getLongHTMLText
81
	 *
82
	 * @since 2.0
83
	 */
84
	public function getLongHTMLText( $linker = null ) {
85
		return $this->getLongWikiText( $linker );
86
	}
87
88
	/**
89
	 * @see SMWDataValue::getWikiValue
90
	 *
91
	 * @since 2.0
92
	 */
93
	public function getWikiValue() {
94
		return $this->m_dataitem->getString();
95
	}
96
97
	/**
98
	 * @see SMWDataValue::getExportData
99
	 *
100
	 * @since 2.0
101
	 */
102
	public function getExportData() {
103
		return null;
104
	}
105
}
106