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 | |
/** | |
* Use invariant() to assert state which your program assumes to be true. | |
* | |
* @throws Exception | |
*/ | |
function invariant(mixed $condition, string $message = 'Invariant Violation', ...$params): void | |
{ | |
if (! $condition) { | |
if (func_num_args() > 2) { |
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 | |
/** | |
* A utility that accepts a value and throws an Exception if the value is null, | |
* otherwise it returns the value. | |
* | |
* @throws Exception | |
*/ | |
function nullthrows(mixed $value, string $message = null): mixed | |
{ |
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
/* | |
Rui Santos | |
Complete project details at https://RandomNerdTutorials.com/esp32-door-status-telegram/ | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files. | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
*/ |
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 | |
class User | |
{ | |
// ... | |
public function hasRole(int $roleId): bool | |
{ | |
return $this->roleId === $roleId; | |
} |
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 | |
use App\Enums\UserRoleTypes; | |
class User | |
{ | |
// ... | |
public function hasRole(int $roleId): bool | |
{ |
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 file is generated. Do not modify it manually! | |
* | |
* This file was generated by: | |
* php artisan make:enum App\Models\UserRoleTypes --model=UserRole --id=Id --slug=Slug --title=Role | |
* If there is a newer version, run: | |
* php artisan make:enum App\Models\UserRoleTypes --model=UserRole --id=Id --slug=Slug --title=Role --force | |
*/ |
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 | |
$response = new \dobron\BigPipe\AsyncResponse(); | |
$response->setContent('div#content', $newContent); | |
$response->send(); |
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 | |
$response = new \dobron\BigPipe\AsyncResponse(); | |
$response->reload(250); // reload page with 250ms delay | |
// or | |
$response->redirect('/onboarding', 500); // redirect with 500ms delay | |
$response->send(); |
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 | |
$response = new \dobron\BigPipe\AsyncResponse(); | |
$response->setPayload([ | |
'username' => $_POST['username'], | |
'status' => 'unavailable', | |
'message' => 'Username is unavailable.', | |
]); | |
$response->send(); |
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 | |
$asyncResponse = new \dobron\BigPipe\AsyncResponse(); | |
// $asyncResponse->bigPipe()->require(["SecretModule", "run"], ... ) | |
// is same as: | |
$asyncResponse->bigPipe()->require("require('SecretModule').run()", [ | |
'first argument', | |
'second argument', | |
// ... | |
]); | |
$asyncResponse->send(); |
NewerOlder