This file contains hidden or 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
| #!/usr/bin/php | |
| <?php | |
| /** | |
| * Script for creating a new Apache2 VHost and MySQL User + Database. | |
| * | |
| * @author Julius Beckmann (github@h4cc.de) | |
| */ | |
| if(6 != count($argv)) { | |
| echo "--- New Vhost --- |
This file contains hidden or 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 | |
| // Switch architecture if needed | |
| if(2147483647 == PHP_INT_MAX) { | |
| $architecture = 'i386'; | |
| }else{ | |
| $architecture = 'amd64'; | |
| } |
This file contains hidden or 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 | |
| function flatten(array $array) | |
| { | |
| return call_user_func_array('array_merge', $array); | |
| } |
This file contains hidden or 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
| // CommandHandler Class | |
| var CommandHandler = function(repository) { | |
| this.handle = function(command) { | |
| // do stuff with repository and command | |
| } | |
| } | |
| // Elsewhere, create an instance of the class... | |
| var myCommandHandler = new CommandHandler(repository); |
This file contains hidden or 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
| var getClass = function() { | |
| var funcNameRegex = /function (.{1,})\(/; | |
| var results = (funcNameRegex).exec((this).constructor.toString()); | |
| return (results && results.length > 1) ? results[1] : ""; | |
| }; | |
| // define a class | |
| function Animal() {} | |
| // do this for all classes that need the getClass() method |
This file contains hidden or 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 BankAccount | |
| { | |
| private $twitter; | |
| public function __construct(Twitter $twitter) | |
| { | |
| $this->twitter = $twitter; | |
| } | |
| public function deposit($amount){ | |
| } |
This file contains hidden or 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 | |
| /** @Entity */ | |
| class Bug | |
| { | |
| /** @Column(type="integer") */ | |
| private $id; | |
| /** @Column(length=50) */ | |
| private $status; | |
| //... | |
| } |
This file contains hidden or 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 Foo | |
| { | |
| private $private; | |
| public function __construct($value) | |
| { | |
| $this->private = $value; | |
| } | |
| public function getOther(Foo $object) | |
| { |
This file contains hidden or 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 | |
| // client code | |
| $customer = $customerRepository->find($id); | |
| $orders = $customer->getOrders(); |
This file contains hidden or 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 Thing { | |
| public function execute(); | |
| } | |
| class A implements Thing { | |
| public function execute() |