Skip to content

Commit

Permalink
Rename classes and interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl authored and enricobattocchi committed Dec 22, 2023
1 parent a0409ed commit b52f464
Show file tree
Hide file tree
Showing 36 changed files with 322 additions and 315 deletions.
7 changes: 4 additions & 3 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@
<!-- Textdomain is passed in dynamically which will not work correctly with gettext().
Ticket: https://github.com/Yoast/whip/issues/2 -->
<rule ref="WordPress.WP.I18n.NonSingularStringLiteralDomain">
<exclude-pattern>/src/Messages/Whip_HostMessage\.php$</exclude-pattern>
<exclude-pattern>/src/Messages/Whip_UpgradePhpMessage\.php$</exclude-pattern>
<exclude-pattern>/src/Messages/HostMessage\.php$</exclude-pattern>
<exclude-pattern>/src/Messages/UpgradePhpMessage\.php$</exclude-pattern>
</rule>

<rule ref="WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound">
<!-- These hook setups should be reviewed.
Ticket: https://github.com/Yoast/whip/issues/67 -->
<exclude-pattern>/src/Whip_Host\.php$</exclude-pattern>
<exclude-pattern>/src/Host\.php$</exclude-pattern>
<exclude-pattern>/src/Messages/UpgradePhpMessage\.php$</exclude-pattern>
</rule>

</ruleset>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"Yoast\\WHIP\\Config\\Composer\\Actions::check_coding_standards"
],
"check-cs-thresholds": [
"@putenv YOASTCS_THRESHOLD_ERRORS=8",
"@putenv YOASTCS_THRESHOLD_ERRORS=10",
"@putenv YOASTCS_THRESHOLD_WARNINGS=0",
"Yoast\\WHIP\\Config\\Composer\\Actions::check_cs_thresholds"
],
Expand Down
22 changes: 11 additions & 11 deletions src/Whip_Configuration.php → src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Yoast\WHIPv2;

use Yoast\WHIPv2\Exceptions\Whip_InvalidType;
use Yoast\WHIPv2\Interfaces\Whip_Requirement;
use Yoast\WHIPv2\Exceptions\InvalidType;
use Yoast\WHIPv2\Interfaces\Requirement;

/**
* Class Whip_Configuration.
* Class Configuration.
*/
class Whip_Configuration {
class Configuration {

/**
* The configuration to use.
Expand All @@ -18,15 +18,15 @@ class Whip_Configuration {
private $configuration;

/**
* Whip_Configuration constructor.
* Configuration constructor.
*
* @param array $configuration The configuration to use.
*
* @throws Whip_InvalidType When the $configuration parameter is not of the expected type.
* @throws InvalidType When the $configuration parameter is not of the expected type.
*/
public function __construct( $configuration = array() ) {
if ( ! \is_array( $configuration ) ) {
throw new Whip_InvalidType( 'Configuration', $configuration, 'array' );
throw new InvalidType( 'Configuration', $configuration, 'array' );
}

$this->configuration = $configuration;
Expand All @@ -35,12 +35,12 @@ public function __construct( $configuration = array() ) {
/**
* Retrieves the configured version of a particular requirement.
*
* @param Whip_Requirement $requirement The requirement to check.
* @param Requirement $requirement The requirement to check.
*
* @return string|int The version of the passed requirement that was detected as a string.
* If the requirement does not exist, this returns int -1.
*/
public function configuredVersion( Whip_Requirement $requirement ) {
public function configuredVersion( Requirement $requirement ) {
if ( ! $this->hasRequirementConfigured( $requirement ) ) {
return -1;
}
Expand All @@ -51,11 +51,11 @@ public function configuredVersion( Whip_Requirement $requirement ) {
/**
* Determines whether the passed requirement is present in the configuration.
*
* @param Whip_Requirement $requirement The requirement to check.
* @param Requirement $requirement The requirement to check.
*
* @return bool Whether or not the requirement is present in the configuration.
*/
public function hasRequirementConfigured( Whip_Requirement $requirement ) {
public function hasRequirementConfigured( Requirement $requirement ) {
return \array_key_exists( $requirement->component(), $this->configuration );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Class EmptyProperty.
*/
class Whip_EmptyProperty extends Exception {
class EmptyProperty extends Exception {

/**
* EmptyProperty constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Class InvalidOperatorType.
*/
class Whip_InvalidOperatorType extends Exception {
class InvalidOperatorType extends Exception {

/**
* InvalidOperatorType constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Class InvalidType.
*/
class Whip_InvalidType extends Exception {
class InvalidType extends Exception {

/**
* InvalidType constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Exception for an invalid version comparison string.
*/
class Whip_InvalidVersionComparisonString extends Exception {
class InvalidVersionComparisonString extends Exception {

/**
* InvalidVersionComparisonString constructor.
Expand Down
20 changes: 10 additions & 10 deletions src/Facades/wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* @package Yoast\WHIP
*/

use Yoast\WHIPv2\Presenters\Whip_WPMessagePresenter;
use Yoast\WHIPv2\Whip_MessageDismisser;
use Yoast\WHIPv2\Whip_RequirementsChecker;
use Yoast\WHIPv2\Whip_VersionRequirement;
use Yoast\WHIPv2\Whip_WPDismissOption;
use Yoast\WHIPv2\MessageDismisser;
use Yoast\WHIPv2\Presenters\WPMessagePresenter;
use Yoast\WHIPv2\RequirementsChecker;
use Yoast\WHIPv2\VersionRequirement;
use Yoast\WHIPv2\WPDismissOption;

if ( ! function_exists( 'whip_wp_check_versions' ) ) {
/**
Expand All @@ -26,10 +26,10 @@ function whip_wp_check_versions( $requirements ) {
}

$config = include __DIR__ . '/../Configs/default.php';
$checker = new Whip_RequirementsChecker( $config );
$checker = new RequirementsChecker( $config );

foreach ( $requirements as $component => $versionComparison ) {
$checker->addRequirement( Whip_VersionRequirement::fromCompareString( $component, $versionComparison ) );
$checker->addRequirement( VersionRequirement::fromCompareString( $component, $versionComparison ) );
}

$checker->check();
Expand All @@ -41,9 +41,9 @@ function whip_wp_check_versions( $requirements ) {
$dismissThreshold = ( WEEK_IN_SECONDS * 4 );
$dismissMessage = __( 'Remind me again in 4 weeks.', 'default' );

$dismisser = new Whip_MessageDismisser( time(), $dismissThreshold, new Whip_WPDismissOption() );
$dismisser = new MessageDismisser( time(), $dismissThreshold, new WPDismissOption() );

$presenter = new Whip_WPMessagePresenter( $checker->getMostRecentMessage(), $dismisser, $dismissMessage );
$presenter = new WPMessagePresenter( $checker->getMostRecentMessage(), $dismisser, $dismissMessage );

// Prevent duplicate notices across multiple implementing plugins.
if ( ! has_action( 'whip_register_hooks' ) ) {
Expand All @@ -53,7 +53,7 @@ function whip_wp_check_versions( $requirements ) {
/**
* Fires during hooks registration for the message presenter.
*
* @param Whip_WPMessagePresenter $presenter Message presenter instance.
* @param WPMessagePresenter $presenter Message presenter instance.
*/
do_action( 'whip_register_hooks', $presenter );
}
Expand Down
2 changes: 1 addition & 1 deletion src/Whip_Host.php → src/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Represents a host.
*/
class Whip_Host {
class Host {

/**
* Key to an environment variable which should be set to the name of the host.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Yoast\WHIPv2\Interfaces;

/**
* Interface Whip_DismissStorage.
* Interface DismissStorage.
*/
interface Whip_DismissStorage {
interface DismissStorage {

/**
* Saves the value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Yoast\WHIPv2\Interfaces;

/**
* Interface Whip_Listener.
* Interface Listener.
*/
interface Whip_Listener {
interface Listener {

/**
* Method that should implement the listen functionality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Yoast\WHIPv2\Interfaces;

/**
* Interface Whip_Message.
* Interface Message.
*/
interface Whip_Message {
interface Message {

/**
* Retrieves the message body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Yoast\WHIPv2\Interfaces;

/**
* Interface Whip_MessagePresenter.
* Interface MessagePresenter.
*/
interface Whip_MessagePresenter {
interface MessagePresenter {

/**
* Renders the message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Yoast\WHIPv2\Interfaces;

/**
* Interface Whip_Requirement.
* Interface Requirement.
*/
interface Whip_Requirement {
interface Requirement {

/**
* Retrieves the component name defined for the requirement.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* An interface that represents a version detector and message.
*/
interface Whip_VersionDetector {
interface VersionDetector {

/**
* Detects the version of the installed software.
Expand Down
16 changes: 8 additions & 8 deletions src/Whip_MessageDismisser.php → src/MessageDismisser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Yoast\WHIPv2;

use Yoast\WHIPv2\Interfaces\Whip_DismissStorage;
use Yoast\WHIPv2\Interfaces\DismissStorage;

/**
* A class to dismiss messages.
*/
class Whip_MessageDismisser {
class MessageDismisser {

/**
* Storage object to manage the dismissal state.
*
* @var Whip_DismissStorage
* @var DismissStorage
*/
protected $storage;

Expand All @@ -31,13 +31,13 @@ class Whip_MessageDismisser {
protected $threshold;

/**
* Whip_MessageDismisser constructor.
* MessageDismisser constructor.
*
* @param int $currentTime The current time.
* @param int $threshold The number of seconds the message will be dismissed.
* @param Whip_DismissStorage $storage Storage object to manage the dismissal state.
* @param int $currentTime The current time.
* @param int $threshold The number of seconds the message will be dismissed.
* @param DismissStorage $storage Storage object to manage the dismissal state.
*/
public function __construct( $currentTime, $threshold, Whip_DismissStorage $storage ) {
public function __construct( $currentTime, $threshold, DismissStorage $storage ) {
$this->currentTime = $currentTime;
$this->threshold = $threshold;
$this->storage = $storage;
Expand Down
2 changes: 1 addition & 1 deletion src/Whip_MessageFormatter.php → src/MessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* A helper class to format messages.
*/
final class Whip_MessageFormatter {
final class MessageFormatter {

/**
* Wraps a piece of text in HTML strong tags.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Yoast\WHIPv2\Messages;

use Yoast\WHIPv2\Exceptions\Whip_EmptyProperty;
use Yoast\WHIPv2\Exceptions\Whip_InvalidType;
use Yoast\WHIPv2\Interfaces\Whip_Message;
use Yoast\WHIPv2\Exceptions\EmptyProperty;
use Yoast\WHIPv2\Exceptions\InvalidType;
use Yoast\WHIPv2\Interfaces\Message;

/**
* Class Whip_Message.
* Class BasicMessage.
*/
class Whip_BasicMessage implements Whip_Message {
class BasicMessage implements Message {

/**
* Message body.
Expand All @@ -19,7 +19,7 @@ class Whip_BasicMessage implements Whip_Message {
private $body;

/**
* Whip_Message constructor.
* Message constructor.
*
* @param string $body Message body.
*/
Expand All @@ -45,16 +45,16 @@ public function body() {
*
* @return void
*
* @throws Whip_EmptyProperty When the $body parameter is empty.
* @throws Whip_InvalidType When the $body parameter is not of the expected type.
* @throws EmptyProperty When the $body parameter is empty.
* @throws InvalidType When the $body parameter is not of the expected type.
*/
private function validateParameters( $body ) {
if ( empty( $body ) ) {
throw new Whip_EmptyProperty( 'Message body' );
throw new EmptyProperty( 'Message body' );
}

if ( ! \is_string( $body ) ) {
throw new Whip_InvalidType( 'Message body', $body, 'string' );
throw new InvalidType( 'Message body', $body, 'string' );
}
}
}
Loading

0 comments on commit b52f464

Please sign in to comment.