public function get($entityId, $lang = 'en') 
    {
        if(!is_qid($entityId)) {
            throw new Exception("First argument in get() must by a valid Wikidata entity ID (e.g.: Q646).", 1);
        }

        $query = '
            SELECT ?item ?itemLabel ?itemDescription ?itemAltLabel ?prop ?propLabel (GROUP_CONCAT(DISTINCT ?valueLabel;separator=", ") AS ?propValue) WHERE { 
                  BIND(wd:'.$entityId.' AS ?item).
                  ?prop wikibase:directClaim ?p .
                  ?item ?p ?value .
                  SERVICE wikibase:label { 
                    bd:serviceParam wikibase:language "'.$lang.'". 
                    ?value rdfs:label ?valueLabel . 
                    ?prop rdfs:label ?propLabel . 
                    ?item rdfs:label ?itemLabel . 
                    ?item skos:altLabel ?itemAltLabel . 
                    ?item schema:description ?itemDescription . 
                  }    
                } group by ?item ?itemLabel ?itemDescription ?itemAltLabel ?prop ?propLabel
        '; 

        $client = new SparqlClient();

        $data = $client->execute($query); 

        if(!$data) {
            return null;
        }

        $entity = new Entity($data, $lang);

        return $entity;
    }
public function get($entityId, $lang = 'en') 
    {
        if(!is_qid($entityId)) {
            throw new Exception("First argument in get() must by a valid Wikidata entity ID (e.g.: Q646).", 1);
        }

        $query = '
            SELECT ?item ?itemLabel ?itemDescription ?itemAltLabel ?prop ?propLabel (GROUP_CONCAT(DISTINCT ?valueLabel;separator=", ") AS ?propValue) WHERE { 
                  BIND(wd:'.$entityId.' AS ?item).
                  ?prop wikibase:directClaim ?p .
                  ?item ?p ?value .
                  SERVICE wikibase:label { 
                    bd:serviceParam wikibase:language "'.$lang.'". 
                    ?value rdfs:label ?valueLabel . 
                    ?prop rdfs:label ?propLabel . 
                    ?item rdfs:label ?itemLabel . 
                    ?item skos:altLabel ?itemAltLabel . 
                    ?item schema:description ?itemDescription . 
                  }    
                } group by ?item ?itemLabel ?itemDescription ?itemAltLabel ?prop ?propLabel
        '; 

        $client = new SparqlClient();

        $data = $client->execute($query); 

        if(!$data) {
            return null;
        }

        $entity = new Entity($data, $lang);

        return $entity;
    }
public function get ( $ entityId , $ lang = 'en' ) { if ( ! is_qid ( $ entityId ) ) { throw new Exception ( "First argument in get() must by a valid Wikidata entity ID (e.g.: Q646)." , 1 ) ; } $ query = '
            SELECT ?item ?itemLabel ?itemDescription ?itemAltLabel ?prop ?propLabel (GROUP_CONCAT(DISTINCT ?valueLabel;separator=", ") AS ?propValue) WHERE { 
                  BIND(wd:' . $ entityId . ' AS ?item).
                  ?prop wikibase:directClaim ?p .
                  ?item ?p ?value .
                  SERVICE wikibase:label { 
                    bd:serviceParam wikibase:language "' . $ lang . '". 
                    ?value rdfs:label ?valueLabel . 
                    ?prop rdfs:label ?propLabel . 
                    ?item rdfs:label ?itemLabel . 
                    ?item skos:altLabel ?itemAltLabel . 
                    ?item schema:description ?itemDescription . 
                  }    
                } group by ?item ?itemLabel ?itemDescription ?itemAltLabel ?prop ?propLabel
        ' ; $ client = new SparqlClient ( ) ; $ data = $ client -> execute ( $ query ) ; if ( ! $ data ) { return null ; } $ entity = new Entity ( $ data , $ lang ) ; return $ entity ; }
Get entity by ID

@param string $entityId Wikidata entity ID (e.g.: Q11696)
@param string $lang Language

@return \Wikidata\Entity Return entity
Get entity by ID