Skip to content

Instantly share code, notes, and snippets.

Avatar
😳
-10x programmer

Kobus kobus1998

😳
-10x programmer
View GitHub Profile
@kobus1998
kobus1998 / script.php
Created Aug 5, 2021
very useful program to sum a bit
View script.php
<?php
$i = (fn($x) => (function ($x) {
return (fn($x) => $x + 1)($x + 1);
})($x + 1));
echo $i(1); // 4
@kobus1998
kobus1998 / MyApiClient.php
Last active Aug 3, 2021
simple api abstraction
View MyApiClient.php
<?php
class MyApiClient
{
use Requestor;
const VERSION = 'v1';
/** @var GuzzleHttp\Client */
private $client;
@kobus1998
kobus1998 / project-structure
Created Jul 30, 2021
example advanced project structure
View project-structure
use Rms\Domains\User\Commands\{ CreateUserCommand, CreateReservationHandler }
use Rms\App\Controllers\{ UserController, ReservationController}
src
- Domains
- User
- UserRepository.php
- UserEntity.php
- Commands
- CreateUserCommand.php
View overheadPerformanceTest.php
<?php
class mod {
public function __construct(private $aMod) {}
public function map($cCall) {
$this->aMod = array_map($cCall, $this->aMod);
return $this;
}
@kobus1998
kobus1998 / StrictSwitch.php
Created May 31, 2021
make a switch type check
View StrictSwitch.php
<?php
class StrictSwitch
{
private $val;
private $done = false;
public function __construct($val)
{
@kobus1998
kobus1998 / test-using-dependency-injection.php
Last active May 14, 2021
test old code using dependency injection
View test-using-dependency-injection.php
<?php
interface Dep {
public function has();
}
// i want to test this function and get 100% code coverage
function depends(Dep $dependency) {
if ($dependency->has()) {
return true;
View fuzzy-finder.php
<?php
$aPages = [
'reservation', 'room type', 'room', 'rate type', 'rate availability', 'settings', 'connectivity'
];
$aTests = [
'rs', 'rt', 'rm', 'rat', 'ra', 'st', 'cnn'
];
@kobus1998
kobus1998 / calculation-structure.php
Created Feb 12, 2021
simple price calculation structure
View calculation-structure.php
<?php
class Price
{
public function getAmount(): int
{
return 0;
}
}
@kobus1998
kobus1998 / extendable-singleton.php
Created Feb 8, 2021
extendable singleton class
View extendable-singleton.php
<?php
class Singleton
{
protected static $instanches = [];
private function __construct()
{
}
@kobus1998
kobus1998 / index.html
Created Jan 8, 2021
create custom html5 form rules
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="/" id="form">
<input type="text" fixed="abc" id="custom">