Skip to content

v3.0.0

Choose a tag to compare

@D3strukt0r D3strukt0r released this 15 Jul 21:16

3.0.0 (2020-10-26)

⚠ BREAKING CHANGES

  • Namespace changed from D3strukt0r\VotifierClient to D3strukt0r\Votifier\Client. Update every use statement.

  • Classes were moved and renamed:

    • ServerType\ClassicVotifierServer\Votifier
    • ServerType\NuVotifierServer\NuVotifier
    • ServerType\ServerTypeInterfaceServer\ServerInterface
    • VoteType\ClassicVoteVote\ClassicVote
    • VoteType\VoteInterfaceVote\VoteInterface
    • ServerConnectionSocket (internal), and the Messages class was removed.
  • Construction is now a fluent builder (no more positional constructors), and you send on the server object directly — the Vote wrapper class is gone. sendVote() is variadic, so several votes can be sent at once:

    // before (2.x)
    $serverType = new ClassicVotifier('127.0.0.1', null, $publicKey);
    $voteType = new ClassicVote($username, 'Your vote list', $ip);
    (new Vote($voteType, $serverType))->send();
    
    // after (3.0.0)
    use D3strukt0r\Votifier\Client\Server\Votifier;
    use D3strukt0r\Votifier\Client\Vote\ClassicVote;
    
    $server = (new Votifier())->setHost('127.0.0.1')->setPublicKey($publicKey); // ->setPort() optional, defaults to 8192
    $vote = (new ClassicVote())->setUsername($username)->setServiceName('Your vote list')->setAddress($ip);
    $server->sendVote($vote);

    For NuVotifier v2: (new NuVotifier())->setHost('127.0.0.1')->setProtocolV2(true)->setToken('...').

  • Failures now throw dedicated typed exceptions instead of a generic \Exception. Catch what you need: Exception\NotVotifierException; the NuVotifier family Exception\NuVotifierChallengeInvalidException, Exception\NuVotifierSignatureInvalidException, Exception\NuVotifierUnknownServiceException, Exception\NuVotifierUsernameTooLongException; and the transport-level Exception\Socket\NoConnectionException, Exception\Socket\PackageNotSentException, Exception\Socket\PackageNotReceivedException. A missing required field throws \InvalidArgumentException.

  • verifyConnection() is available on a server to check reachability before sending.

♻️ Refactoring

  • redesign Vote/Server API and rename to D3strukt0r\Votifier\Client (2978a21)
  • reorganize Server, Vote and Exception class layout (224a1e8)
  • adopt PSR-12 and add dedicated exception classes (9743475)