test adding condorcet vote
This commit is contained in:
@ -0,0 +1,43 @@
|
||||
## public Vote::__construct
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->__construct ( array|string $ranking [, array|string|null $tags = null , ?float $ownTimestamp = null , ?CondorcetPHP\Condorcet\Election $electionContext = null] )
|
||||
```
|
||||
|
||||
Build a vote object.
|
||||
|
||||
|
||||
##### **ranking:** *```array|string```*
|
||||
Equivalent to Vote::setRanking method.
|
||||
|
||||
|
||||
##### **tags:** *```array|string|null```*
|
||||
Equivalent to Vote::addTags method.
|
||||
|
||||
|
||||
##### **ownTimestamp:** *```?float```*
|
||||
Set your own timestamp metadata on Ranking.
|
||||
|
||||
|
||||
##### **electionContext:** *```?CondorcetPHP\Condorcet\Election```*
|
||||
Try to convert directly your candidates from sting input" to Candidate object of one election.
|
||||
|
||||
|
||||
### Throws:
|
||||
|
||||
* ```CondorcetPHP\Condorcet\Throwable\VoteInvalidFormatException```
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::setRanking](../Vote%20Class/public%20Vote--setRanking.md)
|
||||
* [Vote::addTags](../Vote%20Class/public%20Vote--addTags.md)
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Examples and explanation
|
||||
|
||||
* **[Manual - Add Vote](https://github.com/julien-boudry/Condorcet/wiki/II-%23-B.-Vote-management-%23-1.-Add-Vote)**
|
@ -0,0 +1,36 @@
|
||||
## public Vote::addTags
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->addTags ( array|string $tags ): bool
|
||||
```
|
||||
|
||||
Add tag(s) on this Vote.
|
||||
|
||||
|
||||
##### **tags:** *```array|string```*
|
||||
Tag(s) are non-numeric alphanumeric string. They can be added by string separated by commas or an array.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```bool```)* In case of success, return TRUE
|
||||
|
||||
|
||||
|
||||
### Throws:
|
||||
|
||||
* ```CondorcetPHP\Condorcet\Throwable\VoteInvalidFormatException```
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::removeTags](../Vote%20Class/public%20Vote--removeTags.md)
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Examples and explanation
|
||||
|
||||
* **[Manual - Add Vote](https://github.com/julien-boudry/Condorcet/wiki/II-%23-B.-Vote-management-%23-1.-Add-Vote)**
|
@ -0,0 +1,25 @@
|
||||
## public Vote::countLinks
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->countLinks ( ): int
|
||||
```
|
||||
|
||||
Count number of linked election to this object.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```int```)* Number of linked elections.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Candidate::countLinks](../Candidate%20Class/public%20Candidate--countLinks.md)
|
||||
* [Vote::getLinks](../Vote%20Class/public%20Vote--getLinks.md)
|
||||
* [Candidate::getLinks](../Candidate%20Class/public%20Candidate--getLinks.md)
|
||||
* [Vote::haveLink](../Vote%20Class/public%20Vote--haveLink.md)
|
||||
* [Candidate::haveLink](../Candidate%20Class/public%20Candidate--haveLink.md)
|
@ -0,0 +1,15 @@
|
||||
## public Vote::countRankingCandidates
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->countRankingCandidates ( ): int
|
||||
```
|
||||
|
||||
Count the number of candidate provide into the active Ranking set.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```int```)* Number of Candidate into ranking.
|
||||
|
@ -0,0 +1,22 @@
|
||||
## public Vote::getAllCandidates
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getAllCandidates ( ): array
|
||||
```
|
||||
|
||||
Get all the candidates object set in the last ranking of this Vote.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```array```)* Candidates list.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getRanking](../Vote%20Class/public%20Vote--getRanking.md)
|
||||
* [Vote::countRankingCandidates](../Vote%20Class/public%20Vote--countRankingCandidates.md)
|
@ -0,0 +1,31 @@
|
||||
## public Vote::getContextualRanking
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getContextualRanking ( CondorcetPHP\Condorcet\Election $election ): array
|
||||
```
|
||||
|
||||
Return the vote actual ranking complete for the contexte of the provide election. Election must be linked to the Vote object.
|
||||
|
||||
|
||||
##### **election:** *```CondorcetPHP\Condorcet\Election```*
|
||||
An election already linked to the Vote.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```array```)* Contextual full ranking.
|
||||
|
||||
|
||||
|
||||
### Throws:
|
||||
|
||||
* ```CondorcetPHP\Condorcet\Throwable\VoteNotLinkedException```
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getContextualRankingAsString](../Vote%20Class/public%20Vote--getContextualRankingAsString.md)
|
||||
* [Vote::getRanking](../Vote%20Class/public%20Vote--getRanking.md)
|
@ -0,0 +1,26 @@
|
||||
## public Vote::getContextualRankingAsString
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getContextualRankingAsString ( CondorcetPHP\Condorcet\Election $election ): array
|
||||
```
|
||||
|
||||
Return the vote actual ranking complete for the contexte of the provide election. Election must be linked to the Vote object.
|
||||
|
||||
|
||||
##### **election:** *```CondorcetPHP\Condorcet\Election```*
|
||||
An election already linked to the Vote.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```array```)* Contextual full ranking, with string instead Candidate object.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getContextualRanking](../Vote%20Class/public%20Vote--getContextualRanking.md)
|
||||
* [Vote::getRanking](../Vote%20Class/public%20Vote--getRanking.md)
|
@ -0,0 +1,21 @@
|
||||
## public Vote::getCreateTimestamp
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getCreateTimestamp ( ): float
|
||||
```
|
||||
|
||||
Get the timestamp corresponding of the creation of this vote.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```float```)* Timestamp
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Candidate::getTimestamp](../Candidate%20Class/public%20Candidate--getTimestamp.md)
|
@ -0,0 +1,21 @@
|
||||
## public Vote::getHashCode
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getHashCode ( ): string
|
||||
```
|
||||
|
||||
Get Object hash (cryptographic)
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```string```)* SHA hash code.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getWeight](../Vote%20Class/public%20Vote--getWeight.md)
|
@ -0,0 +1,21 @@
|
||||
## public Vote::getHistory
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getHistory ( ): array
|
||||
```
|
||||
|
||||
Return an history of each vote change, with timestamp.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```array```)* An explicit multi-dimenssional array.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getCreateTimestamp](../Vote%20Class/public%20Vote--getCreateTimestamp.md)
|
@ -0,0 +1,25 @@
|
||||
## public Vote::getLinks
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getLinks ( ): WeakMap
|
||||
```
|
||||
|
||||
Get elections object linked to this Vote or Candidate object.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```WeakMap```)* Populated by each elections Condorcet object.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::countLinks](../Vote%20Class/public%20Vote--countLinks.md)
|
||||
* [Candidate::countLinks](../Candidate%20Class/public%20Candidate--countLinks.md)
|
||||
* [Candidate::getLinks](../Candidate%20Class/public%20Candidate--getLinks.md)
|
||||
* [Vote::haveLink](../Vote%20Class/public%20Vote--haveLink.md)
|
||||
* [Candidate::haveLink](../Candidate%20Class/public%20Candidate--haveLink.md)
|
@ -0,0 +1,25 @@
|
||||
## public Vote::getObjectVersion
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getObjectVersion ( [bool $major = false] ): string
|
||||
```
|
||||
|
||||
Get the Condorcet PHP version who built this Election object. Usefull pour serializing Election.
|
||||
|
||||
|
||||
##### **major:** *```bool```*
|
||||
true will return : '2.0' and false will return : '2.0.0'.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```string```)* Condorcet PHP version.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [static Condorcet::getVersion](../Condorcet%20Class/public%20static%20Condorcet--getVersion.md)
|
@ -0,0 +1,25 @@
|
||||
## public Vote::getRanking
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getRanking ( [bool $sortCandidatesInRank = true] ): array
|
||||
```
|
||||
|
||||
Get the actual Ranking of this Vote.
|
||||
|
||||
|
||||
##### **sortCandidatesInRank:** *```bool```*
|
||||
Sort Candidate in a Rank by name. Useful for performant internal calls from methods.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```array```)* Multidimenssionnal array populated by Candidate object.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::setRanking](../Vote%20Class/public%20Vote--setRanking.md)
|
@ -0,0 +1,29 @@
|
||||
## public Vote::getSimpleRanking
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getSimpleRanking ( [?CondorcetPHP\Condorcet\Election $context = null , bool $displayWeight = true] ): string
|
||||
```
|
||||
|
||||
Get the current ranking as a string format. Optionally with an election context, see Election::getContextualRanking()
|
||||
|
||||
|
||||
##### **context:** *```?CondorcetPHP\Condorcet\Election```*
|
||||
An election already linked to the Vote.
|
||||
|
||||
|
||||
##### **displayWeight:** *```bool```*
|
||||
Include or not the weight symbol and value.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```string```)* String like 'A>D=C>B'
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getRanking](../Vote%20Class/public%20Vote--getRanking.md)
|
@ -0,0 +1,23 @@
|
||||
## public Vote::getTags
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getTags ( ): array
|
||||
```
|
||||
|
||||
Get the registered tags for this Vote.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```array```)* List of registered tag.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getTagsAsString](../Vote%20Class/public%20Vote--getTagsAsString.md)
|
||||
* [Vote::addTags](../Vote%20Class/public%20Vote--addTags.md)
|
||||
* [Vote::removeTags](../Vote%20Class/public%20Vote--removeTags.md)
|
@ -0,0 +1,23 @@
|
||||
## public Vote::getTagsAsString
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getTagsAsString ( ): string
|
||||
```
|
||||
|
||||
Get the registered tags for this Vote.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```string```)* List of registered tag as string separated by commas.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getTags](../Vote%20Class/public%20Vote--getTags.md)
|
||||
* [Vote::addTags](../Vote%20Class/public%20Vote--addTags.md)
|
||||
* [Vote::removeTags](../Vote%20Class/public%20Vote--removeTags.md)
|
@ -0,0 +1,21 @@
|
||||
## public Vote::getTimestamp
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getTimestamp ( ): float
|
||||
```
|
||||
|
||||
Get the timestamp corresponding of the last vote change.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```float```)* Timestamp
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getCreateTimestamp](../Vote%20Class/public%20Vote--getCreateTimestamp.md)
|
@ -0,0 +1,25 @@
|
||||
## public Vote::getWeight
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->getWeight ( [?CondorcetPHP\Condorcet\Election $context = null] ): int
|
||||
```
|
||||
|
||||
Get the vote weight. The vote weight capacity must be active at the election level for producing effect on the result.
|
||||
|
||||
|
||||
##### **context:** *```?CondorcetPHP\Condorcet\Election```*
|
||||
In the context of wich election? (optional).
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```int```)* Weight. Default weight is 1.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::setWeight](../Vote%20Class/public%20Vote--setWeight.md)
|
@ -0,0 +1,29 @@
|
||||
## public Vote::haveLink
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->haveLink ( CondorcetPHP\Condorcet\Election $election ): bool
|
||||
```
|
||||
|
||||
Check if this election is linked with this Candidate/Vote object.
|
||||
|
||||
|
||||
##### **election:** *```CondorcetPHP\Condorcet\Election```*
|
||||
Condorcet election to check.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```bool```)* True or False.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::countLinks](../Vote%20Class/public%20Vote--countLinks.md)
|
||||
* [Candidate::countLinks](../Candidate%20Class/public%20Candidate--countLinks.md)
|
||||
* [Vote::getLinks](../Vote%20Class/public%20Vote--getLinks.md)
|
||||
* [Candidate::getLinks](../Candidate%20Class/public%20Candidate--getLinks.md)
|
||||
* [Candidate::haveLink](../Candidate%20Class/public%20Candidate--haveLink.md)
|
@ -0,0 +1,22 @@
|
||||
## public Vote::removeAllTags
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->removeAllTags ( ): bool
|
||||
```
|
||||
|
||||
Remove all registered tag(s) on this Vote.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```bool```)* Return True.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::addTags](../Vote%20Class/public%20Vote--addTags.md)
|
||||
* [Vote::removeTags](../Vote%20Class/public%20Vote--removeTags.md)
|
@ -0,0 +1,30 @@
|
||||
## public Vote::removeCandidate
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->removeCandidate ( CondorcetPHP\Condorcet\Candidate|string $candidate ): bool
|
||||
```
|
||||
|
||||
Remove candidate from ranking. Set a new ranking and archive the old ranking.
|
||||
|
||||
|
||||
##### **candidate:** *```CondorcetPHP\Condorcet\Candidate|string```*
|
||||
Candidate object or string.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```bool```)* True on success.
|
||||
|
||||
|
||||
|
||||
### Throws:
|
||||
|
||||
* ```CondorcetPHP\Condorcet\Throwable\CandidateDoesNotExistException```
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::setRanking](../Vote%20Class/public%20Vote--setRanking.md)
|
@ -0,0 +1,31 @@
|
||||
## public Vote::removeTags
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->removeTags ( array|string $tags ): array
|
||||
```
|
||||
|
||||
Remove registered tag(s) on this Vote.
|
||||
|
||||
|
||||
##### **tags:** *```array|string```*
|
||||
They can be added by string separated by commas or an array.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```array```)* List of deleted tags.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::addTags](../Vote%20Class/public%20Vote--addTags.md)
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Examples and explanation
|
||||
|
||||
* **[Manual - Add Vote](https://github.com/julien-boudry/Condorcet/wiki/II-%23-B.-Vote-management-%23-1.-Add-Vote)**
|
@ -0,0 +1,44 @@
|
||||
## public Vote::setRanking
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->setRanking ( array|string $ranking [, ?float $ownTimestamp = null] ): bool
|
||||
```
|
||||
|
||||
Set a new ranking for this vote.
|
||||
|
||||
Note that if your vote is already linked to one ore more elections, your ranking must be compliant with all of them, else an exception is throw. For do this, you need to use only valid Candidate object, you can't register a new ranking from string if your vote is already linked to an election.
|
||||
|
||||
|
||||
##### **ranking:** *```array|string```*
|
||||
A Ranking. Have a look at the Wiki https://github.com/julien-boudry/Condorcet/wiki/II-%23-B.-Vote-management-%23-1.-Add-Vote to learn the available ranking formats.
|
||||
|
||||
|
||||
##### **ownTimestamp:** *```?float```*
|
||||
Set your own timestamp metadata on Ranking. Your timestamp must be > than last registered timestamp. Else, an exception will be throw.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```bool```)* In case of success, return TRUE
|
||||
|
||||
|
||||
|
||||
### Throws:
|
||||
|
||||
* ```CondorcetPHP\Condorcet\Throwable\VoteInvalidFormatException```
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getRanking](../Vote%20Class/public%20Vote--getRanking.md)
|
||||
* [Vote::getHistory](../Vote%20Class/public%20Vote--getHistory.md)
|
||||
* [Vote::__construct](../Vote%20Class/public%20Vote--__construct.md)
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Examples and explanation
|
||||
|
||||
* **[Manual - Add a vote](https://github.com/julien-boudry/Condorcet/wiki/II-%23-B.-Vote-management-%23-1.-Add-Vote)**
|
@ -0,0 +1,30 @@
|
||||
## public Vote::setWeight
|
||||
|
||||
### Description
|
||||
|
||||
```php
|
||||
public Vote->setWeight ( int $newWeight ): int
|
||||
```
|
||||
|
||||
Set a vote weight. The vote weight capacity must be active at the election level for producing effect on the result.
|
||||
|
||||
|
||||
##### **newWeight:** *```int```*
|
||||
The new vote weight.
|
||||
|
||||
|
||||
### Return value:
|
||||
|
||||
*(```int```)* New weight.
|
||||
|
||||
|
||||
|
||||
### Throws:
|
||||
|
||||
* ```CondorcetPHP\Condorcet\Throwable\VoteInvalidFormatException```
|
||||
|
||||
---------------------------------------
|
||||
|
||||
### Related method(s)
|
||||
|
||||
* [Vote::getWeight](../Vote%20Class/public%20Vote--getWeight.md)
|
Reference in New Issue
Block a user