Completed
Push — master ( 045130...aef0e3 )
by Andrés
03:17
created

BaseDataset   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
getDatasetIdentifier() 0 1 ?
A getData() 0 6 1
1
<?php
2
3
namespace Andreshg112\DatosAbiertos\Datasets;
4
5
use allejo\Socrata\SodaClient;
6
use allejo\Socrata\SodaDataset;
7
8
abstract class BaseDataset
9
{
10
    const SOURCE_DOMAIN = 'datos.gov.co';
11
12
    /** @var SodaClient $sodaClient */
13
    protected $sodaClient;
14
15
    /** @var SodaDataset $sodaDataset */
16
    protected $sodaDataset;
17
18
    public function __construct()
19
    {
20
        $this->sodaClient = new SodaClient(self::SOURCE_DOMAIN, config('datos-abiertos.token'));
21
22
        $this->sodaDataset = new SodaDataset($this->sodaClient, $this->getDatasetIdentifier());
23
    }
24
25
    /**
26
     * Retorna el identificador del dataset o del recurso.
27
     *
28
     * @return string
29
     */
30
    abstract protected function getDatasetIdentifier();
31
32
    /**
33
     * Consulta el listado del recurso de acuerdo a los parámetros.
34
     * Si no se especifican, por defecto trae todos.
35
     * Para saber cómo usar los filtros, consultar en el siguiente enlace:
36
     * https://github.com/allejo/PhpSoda/wiki/Simple-Filters
37
     *
38
     * @param array|string|\allejo\Socrata\SoqlQuery $filterOrSoqlQuery Los parámetros de la consulta.
39
     * @return array[]
40
     */
41
    public function getData($filterOrSoqlQuery = '')
42
    {
43
        $data = $this->sodaDataset->getData($filterOrSoqlQuery);
44
45
        return $data;
46
    }
47
}
48