Blog

SOLID Unit Tests

Set of Unit Tests for the previous SOLID Examples post. Single Responsibility Principle (SRP) Open/Closed Principle (OCP) Liskov Substitution Principle (LSP) Interface Segregation Principle (ISP) Dependency Inversion Principle (DIP) Single Responsibility Principle (SRP) Unit tests for the Authenticator class from the Single Responsibility Principle example from the previous post. use PHPUnit\Framework\TestCase; class AuthenticatorTest extends TestCase { public function testAuthenticateWithValidCredentials() { // Arrange $credentialsValidator = $this->createMock(CredentialsValidator::class); ...

Read More

SOLID Examples

Single Responsibility Principle (SRP) Open/Closed Principle (OCP) Liskov Substitution Principle (LSP) Interface Segregation Principle (ISP) Dependency Inversion Principle (DIP) Single Responsibility Principle (SRP) Suppose you are building a web application that allows users to sign up and log in to their accounts. To handle user authentication, you might create a class called Authenticator that has the following responsibilities: Validate the user's login credentials.Generate a session token if the credentials are valid.Store the session token in a cookie.Redirect ...

Read More

SOLID Principles

As a PHP developer, you can benefit from using SOLID principles to write better, more maintainable code. SOLID stands for: Single Responsibility Principle (SRP) Open/Closed Principle (OCP) Liskov Substitution Principle (LSP)Interface Segregation Principle (ISP) Dependency Inversion Principle (DIP) Here's a brief explanation of each principle and how they can be applied in PHP development: Single Responsibility Principle (SRP) This principle states that a class should have only one responsibility. In other words, a ...

Read More

Sizing Non-LVM Root Partitions

Recently, I was faced with a busy production server with a space problem where the root partition was near capacity. After some research, I determined that it was possible to add space to the RHEL root partition but felt that this would be risky as I did not have experience making this sort of change. Fortunately, I was able to spin up a clone of this system in our QA Environment to ...

Read More