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 | |
/** | |
* Data type to signify a placeholder. | |
*/ | |
class Placeholder {} | |
class_alias('Placeholder', '_'); | |
/** | |
* Recursive array filter. | |
* |
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 | |
/** | |
* This is a functional duplicate of appointment_get_occurances_new() | |
* | |
* Pass this function a schedule and it will return all the dates between $from $to | |
* where an instance of an appointment will occur. If $from is in the past | |
* consider querying for what really happened with the instance table. | |
* | |
* @param array $instances | |
* The instances. |
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 | |
declare(strict_types=1); | |
class Article { | |
public $props; | |
function __construct(int $id, string $title, string $body, DateTime $date) { | |
$this->props = get_defined_vars(); | |
} | |
} |
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 | |
$valid_articles = array_filter([$article], function(Article $article) { | |
return $article->props['body'] == 'sexy'; | |
}); |
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
$article; |
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
$article; |
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 | |
$sellout_articles = array_map(function(Article $article) { | |
$article->props['body'] .= ' TWITTER FACEBOOK <img src="star.bmp"><scriptz src="twitter-likes.js">'; | |
return $article; | |
}, $valid_articles); |
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 | |
$count_sponsor_mentions = array_reduce($sellout_articles, function($count, $value) { | |
if (strpos($value, 'lootbox') !== FALSE) { | |
$count++; | |
} | |
return $count; | |
}, 0); | |
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 | |
$count_sponsor_mentions = array_reduce($sellout_articles, function($count, $value) use($sponsors) { | |
foreach($sponsors as $sponsor) { | |
if (strpos($value, $sponsor) !== FALSE) { | |
$count++; | |
} | |
} | |
return $count; | |
}, 0); |
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 | |
/** | |
* Data type to signify a placeholder. | |
*/ | |
class Placeholder {} | |
class_alias('Placeholder', '_'); | |
/** | |
* Implements partial application with placeholder support. | |
* |