Last active
September 15, 2020 01:01
-
-
Save design-innovations/090dc237717d759d6892cb439174855b to your computer and use it in GitHub Desktop.
PHP - Interfaces
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 | |
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