FIXES IN CODE STYLE

This commit is contained in:
Jeroen De Meerleer 2020-08-02 21:51:59 +02:00
parent c259d5178a
commit 4dbfe27e24
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
23 changed files with 692 additions and 579 deletions

View File

@ -15,32 +15,36 @@
<option name="VARIABLE_NAMING_STYLE" value="CAMEL_CASE" />
<option name="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
<option name="SPACES_AROUND_VAR_WITHIN_BRACKETS" value="true" />
<option name="BLANK_LINES_AROUND_CONSTANTS" value="1" />
<option name="KEEP_BLANK_LINES_AFTER_LBRACE" value="1" />
<option name="BLANK_LINES_AFTER_OPENING_TAG" value="1" />
<option name="KEEP_BLANK_LINES_AFTER_LBRACE" value="0" />
<option name="SPACE_BETWEEN_TERNARY_QUEST_AND_COLON" value="true" />
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
<option name="NEW_LINE_AFTER_PHP_OPENING_TAG" value="true" />
<option name="PLACE_PARENS_FOR_CONSTRUCTOR" value="1" />
</PHPCodeStyleSettings>
<codeStyleSettings language="PHP">
<option name="RIGHT_MARGIN" value="120" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
<option name="BLANK_LINES_AROUND_FIELD" value="1" />
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="SPACE_WITHIN_BRACKETS" value="true" />
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="5" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="EXTENDS_LIST_WRAP" value="5" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
@ -49,11 +53,13 @@
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" />
<option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
<option name="ASSIGNMENT_WRAP" value="5" />
<option name="IF_BRACE_FORCE" value="1" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />

View File

@ -0,0 +1,17 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PhpCSValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="CODING_STANDARD" value="PSR12" />
<option name="EXTENSIONS" value="php,js,css,inc" />
</inspection_tool>
<inspection_tool class="PhpCompoundNamespaceDepthInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpLongTypeFormInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpMissingVisibilityInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpModifierOrderInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpNewClassMissingParameterListInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpSeparateElseIfInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpTraitsUseListInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpVarUsageInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
</profile>
</component>

12
.php_cs
View File

@ -1,12 +0,0 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude(['build', 'vendor'])
->in(__DIR__);
return PhpCsFixer\Config::create()
->setFinder($finder)
->setUsingCache(true)
->setRules([
'@PSR2' => true,
]);

View File

@ -12,6 +12,8 @@ install-dev: ## Installs the required common devtools
@echo "Downloading phpcs"
@wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -O bin/phpcs 2> /dev/null
@wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar -O bin/phpcbf 2> /dev/null
@echo "Adding execution rights on the binaries"
@chmod +x bin/phpcs bin/phpcbf bin/phpdoc
@echo "Installation of devtools finished"
@echo "Please add $(shell echo $(PWD))/bin to your PATH"
@ -54,7 +56,7 @@ clean-repo: ## Cleans the git repository
git gc
cs: ## Fixes coding standard problems
vendor/bin/php-cs-fixer fix || true
php bin/phpcs || true
tag: ## Creates a new signed git tag
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=X.X.X"))

View File

@ -1,13 +1,14 @@
<?php
/**
* Class Constants
*
* Static class for constants
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
@ -20,18 +21,35 @@ use JeroenED\Libpairtwo\Enums\Result;
*
* Static class for constants
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Constants
{
const Won = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned ];
const Draw = [ Result::Draw, Result::DrawAdjourned ];
const Lost = [ Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ];
const NotPlayed = [ Result::Bye, Result::WonBye, Result::Absent ];
const Played = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned, Result::Draw, Result::DrawAdjourned, Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ];
const Black = [ Color::Black ];
const White = [ Color::White ];
public const WON = [Result::WON, Result::WON_FORFAIT, Result::WON_BYE, Result::WON_ADJOURNED];
public const DRAW = [Result::DRAW, Result::DRAW_ADJOURNED];
public const LOST = [Result::ABSENT, Result::BYE, Result::LOST, Result::ADJOURNED];
public const NOTPLAYED = [Result::BYE, Result::WON_BYE, Result::ABSENT];
public const PLAYED = [
Result::WON,
Result::WON_FORFAIT,
Result::WON_BYE,
Result::WON_ADJOURNED,
Result::DRAW,
Result::DRAW_ADJOURNED,
Result::ABSENT,
Result::BYE,
Result::LOST,
Result::ADJOURNED
];
public const BLACK = [Color::BLACK];
public const WHITE = [Color::WHITE];
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Enum Color
*
* List of all compatible colors
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
@ -19,14 +20,16 @@ use MyCLabs\Enum\Enum;
*
* List of all compatible colors
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Color extends Enum
{
const Black = 'B';
const White = 'W';
const None = '*';
public const BLACK = 'B';
public const NONE = '*';
public const WHITE = 'W';
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Enum Gameresult
*
* List of all compatible gameresults
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
@ -19,24 +20,36 @@ use MyCLabs\Enum\Enum;
*
* List of all compatible gameresults
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Gameresult extends Enum
{
const None = '-';
const WhiteWins = '1-0';
const Draw = '0.5-0.5';
const BlackWins = '0-1';
const WhiteWinsForfait = '1-0 FF';
const BlackWinsForfait = '0-1 FF';
const BothLoseForfait = '0-0 FF';
const BothWinAdjourned = '1-1 A';
const WhiteWinsBlackDrawsAdjourned = '1-0.5 A';
const WhiteDrawsBlackWinsAdjourned = '0.5-1 A';
const DrawAdjourned = '0.5-0.5 A';
const WhiteLoseBlackDrawsAdjourned = '0-0.5';
const WhiteDrawsBlackLoseAdjourned = '0.5-0';
public const BLACK_WINS = '0-1';
public const BLACK_WINS_FORFAIT = '0-1 FF';
public const BOTH_LOSE_FORFAIT = '0-0 FF';
public const BOTH_WIN_ADJOURNED = '1-1 A';
public const DRAW = '0.5-0.5';
public const DRAW_ADJOURNED = '0.5-0.5 A';
public const NONE = '-';
public const WHITE_DRAWS_BLACK_LOSE_ADJOURNED = '0.5-0';
public const WHITE_DRAWS_BLACK_WINS_ADJOURNED = '0.5-1 A';
public const WHITE_LOST_BLACK_DRAWS_ADJOURNED = '0-0.5';
public const WHITE_WINS = '1-0';
public const WHITE_WINS_BLACK_DRAWS_ADJOURNED = '1-0.5 A';
public const WHITE_WINS_FORFAIT = '1-0 FF';
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Enum Gender
*
* List of all compatible genders
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
@ -19,14 +20,16 @@ use MyCLabs\Enum\Enum;
*
* List of all compatible genders
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Gender extends Enum
{
const Neutral = 'X'; // Unforturnately, Incompatible with Pairtwo (Dinos)
const Male = 'M';
const Female = 'F';
public const FEMALE = 'F';
public const MALE = 'M';
public const NEUTRAL = 'X'; // Unfortunately, Incompatible with Pairtwo (Dinos)
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Enum Result
*
* List of all compatible results
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
@ -19,22 +20,32 @@ use MyCLabs\Enum\Enum;
*
* List of all compatible results
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Result extends Enum
{
const None = '*';
const Lost = '0';
const Draw = '0.5';
const Won = '1';
const Absent = '0 FF';
const WonForfait = '1 FF';
const Adjourned = '0 A';
const DrawAdjourned = '0.5 A';
const WonAdjourned = '1 A';
const Bye = '0 Bye';
const WonBye = '1 Bye';
public const ABSENT = '0 FF';
public const ADJOURNED = '0 A';
public const BYE = '0 Bye';
public const DRAW = '0.5';
public const DRAW_ADJOURNED = '0.5 A';
public const LOST = '0';
public const NONE = '*';
public const WON = '1';
public const WON_ADJOURNED = '1 A';
public const WON_BYE = '1 Bye';
public const WON_FORFAIT = '1 FF';
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Enum Tiebreak
*
* List of all compatible tiebreaks
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
@ -19,34 +20,56 @@ use MyCLabs\Enum\Enum;
*
* List of all compatible tiebreaks
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Tiebreak extends Enum
{
const None = "";
const Keizer = "Keizer";
const Points = "Points";
const Buchholz = "Buchholz";
const BuchholzMed = "Buchholz Median";
const BuchholzCut = "Buchholz Cut";
const BuchholzMed2 = "Buchholz Median 2";
const BuchholzCut2 = "Buchholz Cut 2";
const Sonneborn = "Sonneborn-Berger";
const Kashdan = "Kashdan";
const SoccerKashdan = "Soccer Kashdan";
const Cumulative = "Cumulative";
const Between = "Mutual Result";
const Koya = "Koya";
const Baumbach = "Most wins"; // Ref: https://en.wikipedia.org/wiki/Tie-breaking_in_Swiss-system_tournaments#Most_wins_(Baumbach) Please tell me why?
const AveragePerformance = "Average performance";
const Performance = "Performance";
const Aro = "Average Rating";
const AroCut = "Average Rating Cut";
const BlackPlayed = "Black played";
const BlackWin = "Black Winned";
const Testmatch = "Testmatch";
const Drawing = "Drawing of lot";
public const ARO = "Average Rating";
public const AROCUT = "Average Rating Cut";
public const AVERAGE_PERFORMANCE = "Average performance";
public const BAUMBACH = "Most wins"; // Ref: https://en.wikipedia.org/wiki/Tie-breaking_in_Swiss-system_tournaments#Most_wins_(Baumbach) Please tell me why?
public const BETWEEN = "Mutual Result";
public const BLACK_PLAYED = "Black played";
public const BLACK_WIN = "Black Winned";
public const BUCHHOLZ = "Buchholz";
public const BUCHHOLZ_CUT = "Buchholz Cut";
public const BUCHHOLZ_CUT_2 = "Buchholz Cut 2";
public const BUCHHOLZ_MED = "Buchholz Median";
public const BUCHHOLZ_MED_2 = "Buchholz Median 2";
public const CUMULATIVE = "Cumulative";
public const DRAWING_OF_LOT = "Drawing of lot";
public const KASHDAN = "Kashdan";
public const KEIZER = "Keizer";
public const KOYA = "Koya";
public const NONE = "";
public const PERFORMANCE = "Performance";
public const POINTS = "Points";
public const SOCCER_KASHDAN = "Soccer Kashdan";
public const SONNEBORN = "Sonneborn-Berger";
public const TESTMATCH = "Testmatch";
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Enum Title
*
* List of all compatible titles
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
@ -19,24 +20,36 @@ use MyCLabs\Enum\Enum;
*
* List of all compatible titles
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Title extends Enum
{
const NONE = '*';
const ELO = 'Elo';
const NM = 'National Master';
const WCM = 'Woman Candidate Master';
const WFM = 'Woman Fide Master';
const CM = 'Candidate Master';
const WIM = 'Woman International Master';
const FM = 'Fide Master';
const WGM = 'Woman Grand Master';
const HM = 'Honorary International Master';
const IM = 'International Master';
const HG = 'Honorary Grand Master';
const GM = 'Grand Master';
public const CM = 'Candidate Master';
public const ELO = 'Elo';
public const FM = 'Fide Master';
public const GM = 'Grand Master';
public const HG = 'Honorary Grand Master';
public const HM = 'Honorary International Master';
public const IM = 'International Master';
public const NM = 'National Master';
public const NONE = '*';
public const WCM = 'Woman Candidate Master';
public const WFM = 'Woman Fide Master';
public const WGM = 'Woman Grand Master';
public const WIM = 'Woman International Master';
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Enum TournamentSystem
*
* List of all compatible tournament systems
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
@ -19,15 +20,18 @@ use MyCLabs\Enum\Enum;
*
* List of all compatible tournament systems
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class TournamentSystem extends Enum
{
const Swiss = 'Swiss';
const Closed = 'Closed';
const American = 'American';
const Keizer = 'Keizer';
public const AMERICAN = 'American';
public const CLOSED = 'Closed';
public const KEIZER = 'Keizer';
public const SWISS = 'Swiss';
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Exception IncompatibleReaderException
*
* Exception to be raised when a reader is used that is incompatible
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Exceptions;
@ -17,10 +18,10 @@ namespace JeroenED\Libpairtwo\Exceptions;
*
* Exception to be raised when a reader is used that is incompatible
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class IncompatibleReaderException extends LibpairtwoException
{

View File

@ -1,27 +1,30 @@
<?php
/**
* Exception LibpairtwoException
*
* General exception when something goes wrong with libpairtwo
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Exceptions;
use Exception;
/**
* Exception LibpairtwoException
*
* General exception when something goes wrong with libpairtwo
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class LibpairtwoException extends \Exception
class LibpairtwoException extends Exception
{
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Class Games
*
* Class for a game of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
@ -21,10 +22,10 @@ use DateTime;
*
* Class for a game of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Game
{
@ -36,7 +37,7 @@ class Game
public $White;
/**
* The pairing for this games as seen from blacks's side
* The pairing for this games as seen from black's side
*
* @var Pairing | null
*/
@ -59,7 +60,8 @@ class Game
/**
* Returns fields that were not directly assigned.
* Class Game contains the special field Result containing the result of the game
* @param string $key
*
* @param string $key
* @return Gameresult
*/
public function __get(string $key)
@ -88,7 +90,7 @@ class Game
$whitesplit = explode(" ", $whiteResult);
$blacksplit = explode(" ", $blackResult);
$special='';
$special = '';
if (isset($whitesplit[1]) && $whitesplit[1] != 'Bye') {
$special = ' ' . $whitesplit[1];
}
@ -110,7 +112,7 @@ class Game
/**
* Checks if 2 games are equal
*
* @param Game $game
* @param Game $game
* @return bool
*/
public function equals(Game $game): bool
@ -118,6 +120,6 @@ class Game
return (
$this->White->Player === $game->White->Player &&
$this->Black->Player === $game->Black->Player &&
$this->Result == $game->Result);
$this->Result->getKey() == $game->Result->getKey());
}
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Class IOFactory
*
* Class for creating readers for pairing files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
@ -21,10 +22,10 @@ use JeroenED\Libpairtwo\Readers\Pairtwo6;
*
* Class for creating readers for pairing files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
abstract class IOFactory
{
@ -45,7 +46,7 @@ abstract class IOFactory
*
* Compatible types are Swar-4, Pairtwo-5, Pairtwo-6
*
* @param string $type
* @param string $type
* @return ReaderInterface
* @throws LibpairtwoException
*/
@ -57,8 +58,7 @@ abstract class IOFactory
// create reader class
$readerClass = self::$Readers[$type];
$reader = new $readerClass;
return $reader;
return new $readerClass();
}
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Interface ReaderInterface
*
* Sets the methods a reader needs to implement
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Interfaces;
@ -19,18 +20,18 @@ use JeroenED\Libpairtwo\Tournament;
*
* Sets the methods a reader needs to implement
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
interface ReaderInterface
{
/**
* Reads out $filename
*
* @param $filename
* @return ReaderInterface
* @param $filename
* @return void
*/
public function read(string $filename): void;
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Class Pairing
*
* Class for a pairing of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
@ -20,10 +21,10 @@ use JeroenED\Libpairtwo\Enums\Result;
*
* Class for a pairing of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Pairing
{
@ -51,6 +52,7 @@ class Pairing
/**
* The result of the Game. Possible values contain Won, Lost, Draw, Forfait, Bye, etc.
*
* @var Result
*/
public $Result;

View File

@ -1,13 +1,14 @@
<?php
/**
* Class Player
*
* Class for a player of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
@ -21,10 +22,10 @@ use DateTime;
*
* Class for a player of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Player
{
@ -122,16 +123,20 @@ class Player
/**
* Returns an array of Player objects where name matches $search
*
* @param string $search
* @param Tournament $tournament
* @param string $search
* @param Tournament $tournament
* @return Player[]
*/
public static function PlayersByName(string $search, Tournament $tournament): array
{
/** @var Player[] */
/**
* @var Player[]
*/
$players = $tournament->Players;
/** @var Player[] */
/**
* @var Player[]
*/
$return = [];
foreach ($players as $player) {
@ -145,7 +150,8 @@ class Player
/**
* Returns the elo of elotype for the player
* @param string $type
*
* @param string $type
* @return int
*/
public function getElo(string $type): int
@ -157,7 +163,7 @@ class Player
* Sets the elo of elotype for the player
*
* @param string $type
* @param int $value
* @param int $value
*/
public function setElo(string $type, int $value): void
{
@ -171,7 +177,7 @@ class Player
*
* Common possible values are Fide or National
*
* @param string $type
* @param string $type
* @return string
*/
public function getId(string $type): string
@ -203,7 +209,7 @@ class Player
{
$wins = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::Won) !== false) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$wins++;
}
}
@ -217,17 +223,17 @@ class Player
* 0.5 points are awarded for draw
* 0 points are awarded for loss
*
* @param int $round
* @param int $round
* @return float
*/
public function calculatePoints(int $round = -1): float
{
$points = 0;
foreach ($this->Pairings as $key=>$pairing) {
foreach ($this->Pairings as $key => $pairing) {
if ($key < $round || $round == -1) {
if (array_search($pairing->Result, Constants::Won) !== false) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$points = $points + 0.5;
}
}
@ -240,13 +246,13 @@ class Player
*
* Return the same score for all rounds until $byeround and added with a half point for each subsequent round
*
* @param int $byeround
* @param int $byeround
* @return float
*/
public function calculatePointsForVirtualPlayer(int $byeround): float
{
$points = $this->calculatePoints($byeround);
foreach (array_slice($this->Pairings, $byeround +1) as $key=>$pairing) {
foreach (array_slice($this->Pairings, $byeround + 1) as $key => $pairing) {
$points += 0.5;
}
return $points;
@ -264,11 +270,11 @@ class Player
{
$points = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NotPlayed) !== false) {
if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
$points = $points + 0.5;
} elseif (array_search($pairing->Result, Constants::Won) !== false) {
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$points = $points + 0.5;
}
}
@ -279,23 +285,23 @@ class Player
*
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution
*
* @param $type
* @param $unratedElo
* @return int
* @param $type
* @param $unratedElo
* @return float
*/
public function Performance(string $type, int $unratedElo): float
{
$total = 0;
$opponents = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NotPlayed) === false) {
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
$opponentElo = $pairing->Opponent->getElo($type);
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
if (array_search($pairing->Result, Constants::Won) !== false) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$total += $opponentElo + 400;
} elseif (array_search($pairing->Result, Constants::Lost) !== false) {
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
$total += $opponentElo - 400;
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$total += $opponentElo;
}
$opponents++;
@ -314,7 +320,7 @@ class Player
{
$total = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::Played) !== false) {
if (array_search($pairing->Result, Constants::PLAYED) !== false) {
$total++;
}
}
@ -324,7 +330,7 @@ class Player
/**
* Returns if player has played against all players of the array
*
* @param Player[] $players
* @param Player[] $players
* @return bool
*/
public function hasPlayedAllPlayersOfArray(array $players): bool
@ -362,7 +368,7 @@ class Player
/**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
*
* @param string $key
* @param string $key
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
@ -382,7 +388,7 @@ class Player
/**
* Sets binary data that is read out the pairing file but is not needed immediately
*
* @param string $key
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void

View File

@ -1,18 +1,19 @@
<?php
/**
* Reader Pairtwo6
*
* Reads out Pairtwo-6 and Pairtwo-5 files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Readers;
use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Result;
@ -32,18 +33,22 @@ use DateTime;
*
* Reads out Pairtwo-6 files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Pairtwo6 implements ReaderInterface
{
const PT_DAYFACTOR = 32;
const PT_MONTHFACTOR = 16;
const PT_YEARFACTOR = 512;
const PT_PASTOFFSET = 117;
const CompatibleVersions = ['6.', '5.'];
public const PT_DAYFACTOR = 32;
public const PT_MONTHFACTOR = 16;
public const PT_YEARFACTOR = 512;
public const PT_PASTOFFSET = 117;
public const COMPATIBLE_VERSIONS = ['6.', '5.'];
/**
* Version of Pairtwo this file was created with
@ -61,6 +66,7 @@ class Pairtwo6 implements ReaderInterface
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
@ -68,7 +74,7 @@ class Pairtwo6 implements ReaderInterface
/**
* Returns binary data that was read out the pairtwo file but was not needed immediately
*
* @param string $key
* @param string $key
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
@ -82,7 +88,7 @@ class Pairtwo6 implements ReaderInterface
/**
* Sets binary data that is read out the pairtwo file but is not needed immediately
*
* @param string $key
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
@ -93,7 +99,7 @@ class Pairtwo6 implements ReaderInterface
/**
* Actually reads the Swar-File
*
* @param string $filename
* @param string $filename
* @throws IncompatibleReaderException
*/
public function read(string $filename): void
@ -109,7 +115,7 @@ class Pairtwo6 implements ReaderInterface
$this->Release = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length;
if (array_search(substr($this->Release, 0, 2), self::CompatibleVersions) === false) {
if (array_search(substr($this->Release, 0, 2), self::COMPATIBLE_VERSIONS) === false) {
throw new IncompatibleReaderException("This file was not created with Pairtwo 5 or higher");
}
@ -261,53 +267,53 @@ class Pairtwo6 implements ReaderInterface
$length = 4;
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
case 1:
$tiebreak = Tiebreak::Buchholz;
$tiebreak = Tiebreak::BUCHHOLZ;
break;
case 2:
$tiebreak = Tiebreak::BuchholzMed;
$tiebreak = Tiebreak::BUCHHOLZ_MED;
break;
case 3:
$tiebreak = Tiebreak::BuchholzCut;
$tiebreak = Tiebreak::BUCHHOLZ_CUT;
break;
case 4:
$tiebreak = Tiebreak::Sonneborn;
$tiebreak = Tiebreak::SONNEBORN;
break;
case 5:
$tiebreak = Tiebreak::Kashdan;
$tiebreak = Tiebreak::KASHDAN;
break;
case 6:
$tiebreak = Tiebreak::Cumulative;
$tiebreak = Tiebreak::CUMULATIVE;
break;
case 7:
$tiebreak = Tiebreak::Between;
$tiebreak = Tiebreak::BETWEEN;
break;
case 8:
$tiebreak = Tiebreak::Koya;
$tiebreak = Tiebreak::KOYA;
break;
case 9:
$tiebreak = Tiebreak::Baumbach;
$tiebreak = Tiebreak::BAUMBACH;
break;
case 10:
$tiebreak = Tiebreak::Performance;
$tiebreak = Tiebreak::PERFORMANCE;
break;
case 11:
$tiebreak = Tiebreak::Aro;
$tiebreak = Tiebreak::ARO;
break;
case 12:
$tiebreak = Tiebreak::AroCut;
$tiebreak = Tiebreak::AROCUT;
break;
case 13:
$tiebreak = Tiebreak::BlackPlayed;
$tiebreak = Tiebreak::BLACK_PLAYED;
break;
case 14:
$tiebreak = Tiebreak::Testmatch;
$tiebreak = Tiebreak::TESTMATCH;
break;
case 15:
$tiebreak = Tiebreak::Drawing;
$tiebreak = Tiebreak::DRAWING_OF_LOT;
break;
case 0:
default:
$tiebreak = Tiebreak::None;
$tiebreak = Tiebreak::NONE;
break;
}
$this->Tournament->addTieBreak(new Tiebreak($tiebreak));