Created
May 27, 2016 09:58
-
-
Save giorrrgio/6ba973dfcffb57bcbf416c9c6bb7f03e to your computer and use it in GitHub Desktop.
Single responsibility principle violation in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Logger | |
{ | |
public function __construct(\PDO $pdo) | |
{ | |
$this->pdo = $pdo; | |
} | |
public function log($message) | |
{ | |
$this->persist($message); | |
} | |
private function persist($message) | |
{ | |
$sql = "INSERT INTO logs(:message)"; | |
$stmt = $this->pdo->prepare($sql); | |
$stmt->bindParam(':message', $message, PDO::PARAM_STR); | |
$stmt->execute(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment