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
#!/bin/bash | |
set -e | |
# @explain this script is run by a cronjob every week | |
### “At 04:00 on Saturday.” | |
### 0 4 * * 6 /opt/backup-owncloud.sh > /home/alex/backup-owncloud.log 2>&1 | |
# @vars defined | |
MAX_BACKUP_FILES=52 # keep my backup files during one year |
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
#!/bin/bash | |
set -e | |
# @explain this script is run by a cronjob every week | |
### “At 04:00 on Friday.” | |
### 0 4 * * 5 /opt/clamscan.sh > /home/alex/clamav.log 2>&1 | |
# @vars defined | |
MAX_FILE_SIZE=128M # do not check files with size higher | |
DIRECTORY_TO_SCAN=/home/web/html/owncloud/ |
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 | |
/** | |
* Open/Closed Principle in PHP | |
*/ | |
interface NameableInterface { | |
public function theName(): void; | |
} | |
class User implements NameableInterface |
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 | |
/** | |
* Open/Closed principle in PHP (not working) | |
*/ | |
class User | |
{ | |
public $name; | |
public $firstname; |
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 | |
/** | |
*** Single Responsibility Principle in PHP (not working) | |
**/ | |
class UserService | |
{ | |
public function updateFromAPI( User $user): User | |
{ | |
// ... |
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 | |
/** | |
* Liskov’s Substitution Principle (LSP) in PHP | |
*/ | |
abstract class CMS | |
{ | |
abstract public function findArticles(int $limit = 10): 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
<?php | |
/** | |
* Interface Segregation Principle (ISP) in PHP | |
* | |
* We have 2 dedicated Interfaces for 2 different needs. | |
*/ | |
interface EntityInterface | |
{ | |
public function getId(): int; |
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 Segregation Principle (ISP) in PHP (not working) | |
*/ | |
// ❌ We have only 1 interface for 2 different needs. | |
interface EntityInterface | |
{ | |
public function getId(): int; | |
public function getName(): string; |
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 | |
/** | |
* Dependency Inversion Principle (DIP) in PHP (not working) | |
*/ | |
class PayPal | |
{ | |
public function pay(int $amount): void | |
{ | |
echo "Discussing with PayPal...\n"; |
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 | |
/** | |
* Dependency Inversion Principle (DIP) in PHP | |
*/ | |
interface PaymentInterface | |
{ | |
public function pay(int $amount): void; | |
} |
OlderNewer