Skip to content

Instantly share code, notes, and snippets.

View makoru-hikage's full-sized avatar
🐮
Perhaps

Kurt Ma. Coll makoru-hikage

🐮
Perhaps
View GitHub Profile
@makoru-hikage
makoru-hikage / MenuService.php
Created August 7, 2017 07:11
The MenuService technique...
<?php
namespace DeltaX\Crud\MenuService;
/**
* Use to process input from Query Strings
* or HTTP Request bodies. Process Data determines
* if it'll a last step.
*
*/
<?php
/**
* Accept an array of instances of
* MenuService. Each will process their
* input data then return their output
* data so the next instance can use
* the output data as their input data.
* When there is no instance left in
* the array, the last one shall be returned
@makoru-hikage
makoru-hikage / continueBreak.php
Last active June 20, 2017 12:11
Shows the use of continue 2 and the problem with switch inside a loop.
<?php
public function setSort(array $items){
$columnOrders = [];
foreach ($items as $item) {
$itemStartsWithAlpha = preg_match('/^\W[A-Za-z]*/', $item);
if (! $itemStartsWithAlpha) {
@makoru-hikage
makoru-hikage / StudentChecklist.php
Created April 9, 2017 21:10
Just some random gist, a demonstration of "return $this" pattern
<?php
namespace DeltaX\Aegis\ModelServices\GradesRegistry;
use DeltaX\Aegis\MenuServices\Checklist;
use Carbon\Carbon;
use DeltaX\Utilities as U;
class StudentChecklist extends Checklist {
@makoru-hikage
makoru-hikage / MenuService.php
Created March 16, 2017 00:02
Still needs to be improved...
<?php
namespace DeltaX\Crud\MenuService;
use DeltaX\ContentAccess\ContentAccessInterface;
/**
* MenuService
*/
@makoru-hikage
makoru-hikage / CourseEnrollmentEligibility.php
Last active March 8, 2017 07:51
Checks if a student is eligible to take a course.
<?php
/**
* CourseEnrollmentEligibility
*/
class CourseEnrollmentEligibility extends ModelService {
/**
@makoru-hikage
makoru-hikage / DetermineFirstPart.sql
Last active March 2, 2017 10:21
A query that determines the 1st part (regardless of division type) of an academic year by means of starting and ending date.
SET @yds = 2016;
SET @yde = 2016;
SET @type = 'Semester';
SELECT
*
FROM
school_calendar
WHERE
part_number = 1
@makoru-hikage
makoru-hikage / SwitchCaseVarTypeTest.php
Last active February 18, 2017 01:45
The correct use of switch case to test a variable's type. Correction for NullIsArray.php
<?php
$dummy= [
'Alpha' => null,
'Beta' => null,
'Charlie' => null
];
switch (gettype($dummy['Alpha'])) {
case 'array' :
echo 'Alpha, according to this switch statement, is Array';
@makoru-hikage
makoru-hikage / NullIsArray.php
Last active February 18, 2017 01:01
It seems that a `null` value is treated as an array()
<?php
$dummy= [
'Alpha' => null,
'Beta' => null,
'Charlie' => null
];
switch ($dummy['Alpha']) {
case is_array($dummy['Alpha']) :
@makoru-hikage
makoru-hikage / studentBySection.sql
Last active February 1, 2017 07:43
Groups all the students in the same section in a given academic term
/**
* INVOLVED TABLES
*
* TABLE: students
* id
* user_id
* degree_id
* ...
*
* TABLE: degrees