Skip to content

Instantly share code, notes, and snippets.

@design-innovations
Last active September 15, 2020 01:01
Show Gist options
  • Save design-innovations/090dc237717d759d6892cb439174855b to your computer and use it in GitHub Desktop.
Save design-innovations/090dc237717d759d6892cb439174855b to your computer and use it in GitHub Desktop.
PHP - Interfaces
<?php
interface FileStorage {
function save($filename, $contents);
function readContents($filename);
}
class LocalDriveFileStorage implements FileStorage {
function save($filename, $contents) {
// Implement logic
}
function readContents($filename) {
// Implement logic
}
}
interface AWSService {
function getRegion();
}
class S3FileStorage implements FileStorage, AWSService {
function save($filename, $contents) {
// Implement logic
}
function readContents($filename) {
// Implement logic
}
function getRegion() {
return 'us-east-1';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment