Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Yoast/whip
Browse files Browse the repository at this point in the history
  • Loading branch information
atimmer committed Mar 11, 2017
2 parents fd27b90 + ecbcf83 commit 3c32dc6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Whip_Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Whip_Configuration {
*/
public function __construct( $configuration = array() ) {
if ( ! is_array( $configuration ) ) {
throw new Whip_InvalidType( "Configuration", gettype( $configuration), "array" );
throw new Whip_InvalidType( 'Configuration', gettype( $configuration), "array" );
}

$this->configuration = $configuration;
Expand Down
10 changes: 5 additions & 5 deletions src/Whip_VersionRequirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,23 @@ public static function fromCompareString( $component, $comparisonString ) {
*/
private function validateParameters( $component, $version, $operator ) {
if ( empty( $component ) ) {
throw new Whip_EmptyProperty( "Component" );
throw new Whip_EmptyProperty( 'Component' );
}

if ( !is_string( $component ) ) {
throw new Whip_InvalidType( "Component", "string", $component );
throw new Whip_InvalidType( 'Component', 'string', $component );
}

if ( empty( $version ) ) {
throw new Whip_EmptyProperty( "Version" );
throw new Whip_EmptyProperty( 'Version' );
}

if ( !is_string( $version ) ) {
throw new Whip_InvalidType( "Version", "string", $version );
throw new Whip_InvalidType( 'Version', 'string', $version );
}

if ( empty( $operator ) ) {
throw new Whip_EmptyProperty( "Operator" );
throw new Whip_EmptyProperty( 'Operator' );
}

if ( !is_string( $operator ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/exceptions/Whip_EmptyProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
class Whip_EmptyProperty extends Exception {
public function __construct( $property ) {
parent::__construct( sprintf( "%s cannot be empty.", (string) $property ) );
parent::__construct( sprintf( '%s cannot be empty.', (string) $property ) );
}
}
2 changes: 1 addition & 1 deletion src/exceptions/Whip_InvalidType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Whip_InvalidType extends Exception {
* @param string $expectedType
*/
public function __construct( $property, $value, $expectedType ) {
parent::__construct( sprintf( "%s should be of type %s. Found %s.", $property, $expectedType, gettype( $value ) ) );
parent::__construct( sprintf( '%s should be of type %s. Found %s.', $property, $expectedType, gettype( $value ) ) );
}
}
4 changes: 2 additions & 2 deletions src/messages/Whip_BasicMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public function body() {

private function validateParameters( $body ) {
if ( empty( $body ) ) {
throw new Whip_EmptyProperty( "Message body" );
throw new Whip_EmptyProperty( 'Message body' );
}

if ( ! is_string( $body ) ) {
throw new Whip_InvalidType( "Message body", "string", $body );
throw new Whip_InvalidType( 'Message body', "string", $body );
}
}
}
4 changes: 2 additions & 2 deletions src/messages/Whip_UpgradePhpMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function body() {
$message[] = Whip_MessageFormatter::paragraph( __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Yoast SEO are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you to this notice.', $textdomain ) );
$message[] = Whip_MessageFormatter::paragraph( __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', $textdomain ) );
$message[] = Whip_MessageFormatter::strongParagraph( __( 'To which version should I update?', $textdomain ) ) . '<br />';
$message[] = Whip_MessageFormatter::paragraph( __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. We have an article on how to test whether that\'s an option for you here. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', $textdomain ) );
$message[] = Whip_MessageFormatter::paragraph( sprintf( __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. We have an article on how to test whether that\'s an option for you %1$shere%2$s. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', $textdomain ), '<a href="https://yoa.st/wg" target="_blank">', '</a>' ) );

if ( Whip_Host::name() !== '' ) {
$hostMessage = new Whip_HostMessage( 'WHIP_MESSAGE_FROM_HOST_ABOUT_PHP', $textdomain );
Expand All @@ -44,7 +44,7 @@ public function body() {
$message[] = Whip_MessageFormatter::strongParagraph( __( 'Can\'t update? Ask your host!', $textdomain ) ) . '<br />';

if ( function_exists( 'apply_filters' ) && apply_filters( Whip_Host::HOSTING_PAGE_FILTER_KEY, false ) ) {
$message[] = Whip_MessageFormatter::paragraph( sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have examples here. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', $textdomain ), sprintf( '<a href="%1$s" target="_blank">', esc_url( $hostingPageUrl ) ), '</a>' ) );
$message[] = Whip_MessageFormatter::paragraph( sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %3$sWordPress hosting partners%4$s.', $textdomain ), '<a href="https://yoa.st/wh" target="_blank">', '</a>', sprintf( '<a href="%1$s" target="_blank">', esc_url( $hostingPageUrl ) ), '</a>' ) );
} else {
$message[] = Whip_MessageFormatter::paragraph( sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have examples here. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of our recommended %1$sWordPress hosting partners%2$s, they\'ve all been vetted by our Yoast support team and provide all the features a modern host should provide.', $textdomain ), sprintf( '<a href="%1$s" target="_blank">', esc_url( $hostingPageUrl ) ), '</a>' ) );
}
Expand Down
2 changes: 2 additions & 0 deletions src/presenters/Whip_WPMessagePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function kses( $message ) {
),
'strong' => true,
'p' => true,
'ul' => true,
'li' => true,
) );
}
}
4 changes: 2 additions & 2 deletions tests/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MessageTest extends PHPUnit_Framework_TestCase {
public function testMessageHasBody() {
$message = new Whip_BasicMessage( "This is a message" );
$message = new Whip_BasicMessage( 'This is a message' );

$this->assertNotEmpty($message->body());
}
Expand All @@ -11,7 +11,7 @@ public function testMessageHasBody() {
* @expectedException Whip_EmptyProperty
*/
public function testMessageCannotBeEmpty() {
new Whip_BasicMessage( "" );
new Whip_BasicMessage( '' );
}

/**
Expand Down

0 comments on commit 3c32dc6

Please sign in to comment.