Test Failed
Push — master ( f72e60...12707b )
by Enrico
01:32
created

AbstractAMLO   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 68
ccs 8
cts 14
cp 0.5714
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addIdentifier() 0 12 4
A addPartyInRole() 0 10 5
1
<?php
2
namespace AMLO\Model;
3
4
/*
5
 * Some helpers for AMLO ontology
6
 */
7
abstract class AbstractAMLO extends \BOTK\Model\AbstractModel
8
{
9
    
10
    protected static $DEFAULT_OPTIONS = [
11
        'ndg-registry-uri' => [ 
12
            'default'=> 'urn:resource:undefined-ndg-registry',
13
            'filter'=>FILTER_CALLBACK, 
14
            'options'=>'\BOTK\Filters::FILTER_VALIDATE_URI', 
15
            'flags'=> FILTER_REQUIRE_SCALAR
16
        ],
17
    ];
18
    
19
	protected static $VOCABULARY  = [
20
	   'fibo-fnd-dt-oc'    	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/DatesAndTimes/Occurrences/',
21
	   'fibo-fnd-pas-pas'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/ProductsAndServices/ProductsAndServices/',
22
	   'fibo-fnd-arr-rt'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Ratings/',
23
	   'fibo-fnd-arr-rep'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Reporting/',
24
	   'fibo-fnd-arr-doc'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Documents/',
25
	   'fibo-fnd-arr-asmt'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Assessments/',
26
	   'fibo-fnd-arr-id'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/IdentifiersAndIndices/',
27
	   'fibo-fnd-acc-cur'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Accounting/CurrencyAmount/',
28
	   'fibo-fnd-qt-qtu'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Quantities/QuantitiesAndUnits/',
29
	   'fibo-fnd-acc-4217'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Accounting/ISO4217-CurrencyCodes/',
30
	   'fibo-fnd-rel-rel'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Relations/Relations/',
31
	   'fibo-fnd-aap-agt'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/AgentsAndPeople/Agents/',
32
	   'fibo-fnd-aap-ppl'   =>  'https://spec.edmcouncil.org/fibo/ontology/FND/AgentsAndPeople/People/',
33
	   'fibo-fnd-pty-pty'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Parties/Parties/',
34
	   'fibo-be-oac-exec'	=>  'https://spec.edmcouncil.org/fibo/ontology/BE/OwnershipAndControl/Executives/',
35
	   'fibo-fbc-pas-caa'	=>  'https://spec.edmcouncil.org/fibo/ontology/FBC/ProductsAndServices/ClientsAndAccounts/',
36
	   'amlo' =>  'http://w3id.org/amlo/core#',
37
	];
38
	
39
	/**
40
	 * adds a FIBO idenfifier
41
	 *     $idenfiedURI, $registryURI, $idURI must be URIs
42
	 *     $id is  valid RDF PATH identifier
43
	 *     $type is a CURI using available vocabulary prefixes
44
	 */
45 1
	protected function addIdentifier($idenfiedURI, $type, $id, $registryURI=null, $idURI=null)
46
	{
47 1
	    assert( !empty($type) && !empty($id) && !empty($idenfiedURI) );
48
	    
49 1
	    $subjectIdURI = $idURI?:$this->getURI($id, '_id') ;
50 1
	    $this->addFragment("<$subjectIdURI> fibo-fnd-rel-rel:hasTag \"%s\" ;", $id, false);
51 1
	    $this->addFragment(" fibo-fnd-aap-agt:identifies <%s> ;", $idenfiedURI, false );
52 1
	    $this->addFragment(" fibo-fnd-rel-rel:isDefinedIn <%s> ;", $registryURI ,false );
53 1
	    $this->addFragment(" a %s .", $type ,false);
54
	    
55 1
	    return $this;
56
	}
57
	
58
	
59
	/**
60
	 * adds a party in role
61
	 *     $subjectURI, $partyURI and $relURI must be URIs
62
	 *     $role is a CURI using available vocabulary prefixes
63
	 */
64
	protected function addPartyInRole($subjectURI, $partyURI, $role, $relURI=null)
65
	{
66
	    assert( !empty($subjectURI) && !empty($partyURI) && !empty($role) );
67
	    $relURI = $relURI?:$idURI?:$this->getURI(null, '_party-in-role');
0 ignored issues
show
Bug introduced by
The variable $idURI does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
68
	    
69
	    $this->rdf .= "<$subjectURI> fibo-fnd-pty-pty:hasPartyInRole <$relURI> . <$relURI> a $role ; fibo-fnd-rel-rel:hasIdentity <$partyURI>  .";
70
	    $this->tripleCount += 3;
71
	    
72
	    return $this;
73
	}
74
}