Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
SingleInstance
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
8 / 8
9
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPreferred
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getIterator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 details
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isPreferred
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 analisysExists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addAnalysis
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 countAnalysis
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Dbmi\Webservice\Contributor;
3
4use ArrayIterator;
5use IteratorAggregate;
6use Traversable;
7
8use Dbmi\Webservice\Analysis\SingleInstance as Analysis_Single;
9use Dbmi\Webservice\Contributor\Struct as DS_Contributor;
10use Dbmi\Webservice\Quake\IdStruct as DS_QuakeId;
11
12/**
13 * Contributors descriptor
14 * 
15 * @param Dbmi\Webservice\Contributor\Struct $details Contributor data structure
16 * @param Dbmi\Webservice\Quake\IdStruct $quakeId Quake ID in DBMI format
17 * @param bool $preferred True if this contributor is preferred, false otherwise
18 */
19class SingleInstance implements IteratorAggregate{
20    private DS_Contributor $details;
21    private DS_QuakeId $quakeId;
22    private bool $preferred = false;
23
24    private array $analysis = array();
25
26    private int $curlErrNum = 0;
27    private string $curlErrInfo = '';
28
29    public function __construct(DS_Contributor $details, DS_QuakeId $quakeId, bool $preferred = false){
30        $this->details = $details;
31        $this->quakeId = $quakeId;
32        $this->preferred = $preferred;
33    }
34
35    /**
36     * set this contributor as (not) preferred
37     * 
38     * @param bool $status    True if this contributor is preferred, false otherwise
39     */
40    public function setPreferred(bool $status):void { $this->preferred = $status; }
41    
42    /**
43     * get all analysis
44     * 
45     * @return array array of strings with the found contributors
46     */
47    public function getIterator():Traversable{ return new ArrayIterator($this->analysis); }
48
49    /**
50     * get contributor details
51     * 
52     * @return Dbmi\Webservice\Contributor\Struct    Contributor details
53     */
54    public function details():DS_Contributor{ return $this->details; } 
55
56    /**
57     * get this contributor preferred status
58     * 
59     * @return bool True if this contributor is preferred, false otherwise
60     */
61    public function isPreferred():bool{ return $this->preferred; }
62
63    /**
64     * check if an analysis exist for this contributor
65     * 
66     * @param string $name name of the analysis to check ('MCS', 'EMS', ...)
67     * 
68     * @return bool True if exists, false otherwise
69     */
70    public function analisysExists(string $name):bool{ return array_key_exists($name, $this->analysis); }
71
72    /**
73     * Add Analysys type, can be called multiple times,
74     *     analysis with the same name are renamed in $name-$i++ (where $i >= 1) 
75     * 
76     * @param string type of analysis to search
77     */
78    public function addAnalysis(string $name):void { 
79        $i = 1;
80        $usableName = $name;
81        while( array_key_exists($usableName, $this->analysis) )
82            $usableName = sprintf("%s-%d", $name, $i++);
83
84        $this->analysis[$usableName] = new Analysis_Single($this->details, $this->quakeId); 
85    }
86
87    /**
88     * Get number of Analysys found
89     * 
90     * @return int analysis found
91     */
92    public function countAnalysis():int { return count($this->analysis); }
93}
94
95?>
96

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

SingleInstance->__construct
29    public function __construct(DS_Contributor $details, DS_QuakeId $quakeId, bool $preferred = false){
30        $this->details = $details;
31        $this->quakeId = $quakeId;
32        $this->preferred = $preferred;
33    }
SingleInstance->addAnalysis
78    public function addAnalysis(string $name):void { 
79        $i = 1;
80        $usableName = $name;
81        while( array_key_exists($usableName, $this->analysis) )
81        while( array_key_exists($usableName, $this->analysis) )
82            $usableName = sprintf("%s-%d", $name, $i++);
81        while( array_key_exists($usableName, $this->analysis) )
84        $this->analysis[$usableName] = new Analysis_Single($this->details, $this->quakeId); 
85    }
SingleInstance->analisysExists
70    public function analisysExists(string $name):bool{ return array_key_exists($name, $this->analysis); }
SingleInstance->countAnalysis
92    public function countAnalysis():int { return count($this->analysis); }
SingleInstance->details
54    public function details():DS_Contributor{ return $this->details; } 
SingleInstance->getIterator
47    public function getIterator():Traversable{ return new ArrayIterator($this->analysis); }
SingleInstance->isPreferred
61    public function isPreferred():bool{ return $this->preferred; }
SingleInstance->setPreferred
40    public function setPreferred(bool $status):void { $this->preferred = $status; }