Can you provide examples of practical applications of OOP in PHP, such as in a login system or data storage?

Issue: Implementing a login system using Object-Oriented Programming in PHP can help organize and manage user authentication efficiently.

<?php
// User class to handle user data
class User {
    private $username;
    private $password;

    public function __construct($username, $password) {
        $this->username = $username;
        $this->password = $password;
    }

    public function getUsername() {
        return $this->username;
    }

    public function getPassword() {
        return $this->password;
    }
}

// Login class to authenticate users
class Login {
    public function authenticate(User $user) {
        // Check if username and password match in the database
        if ($user->getUsername() === 'admin' && $user->getPassword() === 'password') {
            return true;
        } else {
            return false;
        }
    }
}

// Usage
$user = new User('admin', 'password');
$login = new Login();

if ($login->authenticate($user)) {
    echo 'Login successful';
} else {
    echo 'Login failed';
}
?>