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 AppStoreConnectAPIClient | |
{ | |
... | |
/** | |
* Return all prices indexed by currency code, given a subscription group ID and a product ID. | |
* @return array<int|string, array<string,mixed>> | |
*/ |
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 | |
//uses Zumba Core HTTP as facade | |
function getToken(): string | |
{ | |
$zoomAccountId = ''; | |
$zoomClientId = ''; | |
$zoomClientSecret = ''; | |
$zoomOAuthUrl = 'https://zoom.us/oauth/token'; //note that this is not the same URL as the one for the API |
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
1. Exception handlers | |
- Handle Exception hierarchy and translate into suitable HTTP response codes (or whatever the protocol is) | |
2. SRP | |
- One file per user story | |
- Fight against query hell | |
3. Materialize inputs and outputs (requests and responses) | |
3. Achieve a clear separation of config files | |
- External services | |
- Data stores | |
- Constants |
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 | |
trait WithDynamicAssignment | |
{ | |
public function set( | |
mixed $dest, | |
array $props, | |
string $field, | |
string $type = 'string', | |
mixed $default = null |
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
# Checks whether all imported modules belong to domain objects inside domain | |
# Imported files must | |
# 1. have a relative path, | |
# 2. have the module's name enclosed by single or double quotes and | |
# 3. not propagate outside the domain | |
filename=check_domain_imports.txt | |
basedir="src/Domain/" | |
grep -r -n 'import ' src/Domain/ > $filename |
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 Random | |
{ | |
public static function distributed($elements) | |
{ | |
if (array_sum($elements) !== 100) { | |
throw new \Exception('randomWithDistribution: sum of probabilities must be 100'); |
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 randomWithDistribution(array $elements) { | |
if(array_sum($elements) !== 100) { | |
throw new \Exception('randomWithDistribution: sum of probabilities must be 100'); | |
} | |
$random = rand(1, 100); | |
$tot = 0; | |
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 | |
/* | |
usage: | |
$ php -f .\show_composer_lock_reqs.php | |
$ php -f .\show_composer_lock_reqs.php /my/base/dir/ (note the slash at the end) | |
*/ | |
array_walk( | |
array_reduce ( |