Passed
Push — master ( 12707b...01168b )
by Enrico
11:38 queued 11:28
created

AbstractAMLO::addPartyInRole()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
c 0
b 0
f 0
cc 4
nc 2
nop 4
crap 4
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
    
11
	protected static $VOCABULARY  = [
12
	   'fibo-fnd-dt-oc'    	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/DatesAndTimes/Occurrences/',
13
	   'fibo-fnd-pas-pas'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/ProductsAndServices/ProductsAndServices/',
14
	   'fibo-fnd-arr-rt'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Ratings/',
15
	   'fibo-fnd-arr-rep'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Reporting/',
16
	   'fibo-fnd-arr-doc'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Documents/',
17
	   'fibo-fnd-arr-asmt'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/Assessments/',
18
	   'fibo-fnd-arr-id'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Arrangements/IdentifiersAndIndices/',
19
	   'fibo-fnd-acc-cur'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Accounting/CurrencyAmount/',
20
	   'fibo-fnd-qt-qtu'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Quantities/QuantitiesAndUnits/',
21
	   'fibo-fnd-acc-4217'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Accounting/ISO4217-CurrencyCodes/',
22
	   'fibo-fnd-rel-rel'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Relations/Relations/',
23
	   'fibo-fnd-aap-agt'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/AgentsAndPeople/Agents/',
24
	   'fibo-fnd-aap-ppl'   =>  'https://spec.edmcouncil.org/fibo/ontology/FND/AgentsAndPeople/People/',
25
	   'fibo-fnd-pty-pty'	=>  'https://spec.edmcouncil.org/fibo/ontology/FND/Parties/Parties/',
26
	   'fibo-be-oac-exec'	=>  'https://spec.edmcouncil.org/fibo/ontology/BE/OwnershipAndControl/Executives/',
27
	   'fibo-fbc-pas-caa'	=>  'https://spec.edmcouncil.org/fibo/ontology/FBC/ProductsAndServices/ClientsAndAccounts/',
28
	   'amlo' =>  'http://w3id.org/amlo/core#',
29
	];
30
	
31
	/**
32
	 * adds a FIBO idenfifier
33
	 *     $idenfiedURI, $registryURI, $idURI must be URIs
34
	 *     $id is  valid RDF PATH identifier
35
	 *     $type is a CURI using available vocabulary prefixes
36
	 */
37 1
	protected function addIdentifier($idenfiedURI, $type, $id, $registryURI=null, $idURI=null)
38
	{
39 1
	    assert( !empty($type) && !empty($id) && !empty($idenfiedURI) );
40
	    
41 1
	    $subjectIdURI = $idURI?:$this->getURI($id, '_id') ;
42 1
	    $this->addFragment("<$subjectIdURI> fibo-fnd-rel-rel:hasTag \"%s\";", $id, false);
43 1
	    $this->addFragment("fibo-fnd-aap-agt:identifies <%s>;", $idenfiedURI, false );
44 1
	    $this->addFragment("fibo-fnd-rel-rel:isDefinedIn <%s>;", $registryURI ,false );
45 1
	    $this->addFragment("a %s .", $type ,false);
46
	    
47 1
	    return $this;
48
	}
49
	
50
	
51
	/**
52
	 * adds a party in role
53
	 *     $subjectURI, $partyURI and $relURI must be URIs
54
	 *     $role is a CURI using available vocabulary prefixes
55
	 */
56 1
	protected function addPartyInRole($subjectURI, $partyURI, $role, $relURIForced=null)
57
	{
58 1
	    assert( !empty($subjectURI) && !empty($partyURI) && !empty($role) );
59 1
	    $relURI = $relURIForced?:$this->getURI(null, '_party-in-role');
60
	    
61 1
	    $this->addFragment("<$subjectURI> fibo-fnd-pty-pty:hasPartyInRole <%s>.", $relURI, false);
62 1
	    $this->addFragment("<$relURI> a %s ;", $role, false);
63 1
	    $this->addFragment("fibo-fnd-rel-rel:hasIdentity <%s>.", $partyURI, false);
64
	    
65 1
	    return $this;
66
	}
67
}