Passed
Push — master ( 4ab488...bcfbc7 )
by Bálint
03:58
created

WordPressDataService   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 6
dl 0
loc 59
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getService() 0 24 10
A initialize() 0 7 1
1
<?php
2
3
use POData\Configuration\EntitySetRights;
4
require_once 'POData\IBaseService.php';
5
require_once 'POData\IRequestHandler.php';
6
require_once 'POData\DataService.php';
7
require_once 'POData\IServiceProvider.php';
8
use POData\Configuration\ProtocolVersion;
9
use POData\Configuration\ServiceConfiguration;
10
use POData\BaseService;
11
require_once 'WordPressMetadata.php';
12
require_once 'WordPressQueryProvider.php';
13
require_once 'WordPressDSExpressionProvider.php';
14
15
16
class WordPressDataService extends BaseService
17
{
18
    private $_wordPressMetadata = null;
19
    private $_wordPressQueryProvider = null;
20
    private $_wordPressExpressionProvider = null;
21
    
22
    /**
23
     * This method is called only once to initialize service-wide policies
24
     * 
25
     * @param ServiceConfiguration $config Data service configuration object
26
     * 
27
     * @return void
28
     */
29
    public function initialize(ServiceConfiguration $config)
30
    {
31
        $config->setEntitySetPageSize('*', 5);
32
        $config->setEntitySetAccessRule('*', EntitySetRights::ALL);
0 ignored issues
show
Bug introduced by
POData\Configuration\EntitySetRights::ALL of type integer is incompatible with the type POData\Configuration\EntitySetRights expected by parameter $rights of POData\Configuration\Ser...etEntitySetAccessRule(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        $config->setEntitySetAccessRule('*', /** @scrutinizer ignore-type */ EntitySetRights::ALL);
Loading history...
33
        $config->setAcceptCountRequests(true);
34
        $config->setAcceptProjectionRequests(true);
35
        $config->setMaxDataServiceVersion(ProtocolVersion::V3());
36
    }
37
38
    /**
39
     * Get the service like IMetadataProvider, IDataServiceQueryProvider,
40
     * IStreamProvider
41
     * 
42
     * @param String $serviceType Type of service IMetadataProvider,
43
     *                            IDataServiceQueryProvider,
44
     *                            IStreamProvider
45
     * 
46
     * @see library/POData.IServiceProvider::getService()
47
     * @return object
48
     */
49
    public function getService($serviceType)
50
    {
51
        if (($serviceType === 'IMetadataProvider') ||
52
        ($serviceType === 'IQueryProvider') ||
53
        ($serviceType === 'IStreamProvider')) {
54
        if (is_null($this->_wordPressExpressionProvider)) {
55
        $this->_wordPressExpressionProvider = new WordPressDSExpressionProvider();    			
56
        }    	
57
        }
58
        if ($serviceType === 'IMetadataProvider') {
59
            if (is_null($this->_wordPressMetadata)) {
60
                $this->_wordPressMetadata = CreateWordPressMetadata::create();
61
                // $this->_wordPressMetadata->mappedDetails = CreateWordPressMetadata::mappingInitialize();
62
            }
63
            return $this->_wordPressMetadata;
64
        } else if ($serviceType === 'IQueryProvider') {
65
            if (is_null($this->_wordPressQueryProvider)) {
66
                $this->_wordPressQueryProvider = new WordPressQueryProvider();
67
            }
68
            return $this->_wordPressQueryProvider;
69
        } else if ($serviceType === 'IStreamProvider') {
70
            return new WordPressStreamProvider();
0 ignored issues
show
Bug introduced by
The type WordPressStreamProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
71
        }
72
        return null;
73
    }
74
}
75