Skip to content

Instantly share code, notes, and snippets.

@giorrrgio
Created May 27, 2016 09:58
Show Gist options
  • Save giorrrgio/6ba973dfcffb57bcbf416c9c6bb7f03e to your computer and use it in GitHub Desktop.
Save giorrrgio/6ba973dfcffb57bcbf416c9c6bb7f03e to your computer and use it in GitHub Desktop.
Single responsibility principle violation in PHP
<?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