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
$sentence = new RegExp('>([\w\d\$\.\,\:\-\%\s]+[^\s])\s+</') |
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 | |
namespace World; | |
interface MarriageContract | |
{ | |
public function engageTo(Person $partner): string; | |
} | |
class Person implements MarriageContract |
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
// Example: controller@index to ['controller', 'index'] | |
// Search. Note: make sure you have space at the start. | |
'(.*)@(.*?)' | |
// Replace | |
\[$1::class, '$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 | |
/** | |
* Helper class to deal with placeholders and xml tags which should be replace in given text | |
* | |
* ---------- Example ---------- | |
* $sampleText = 'This is the <bold-underline>sample</bold-underline> code of {{user}}'. | |
* $placeholders = ['user' => 'Mohammed Mudassir']; | |
* $xml = ['bold-underline' => '<b style="text-decoration: underline'>%</b>'] | |
* |
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 Exception; | |
use Illuminate\Support\Collection; | |
use SplFileObject; | |
/** | |
* CSV loader is a helper class to load data into Laravel Collection | |
* | |
* ---------------------------------------------------------------------------------------------------------------- |
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 an algo to replace all the natural numbers with zero (horizontally and vertically). | |
* This was an interview question to solve. | |
* | |
* If you have more better solution with less iteration will be appreciated. | |
* | |
* @author Mohammed Mudasir <[email protected]> | |
**/ |
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 | |
namespace App\Http\Controllers\Api; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use Illuminate\Foundation\Bus\DispatchesJobs; | |
use Illuminate\Routing\Controller as BaseController; | |
use Illuminate\Foundation\Validation\ValidatesRequests; |
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 | |
/** | |
* Recursively get all values from array | |
* | |
* @param array $array | |
* @param bool $merge maintain array dimension | |
* @return array | |
* | |
* @author Mohammed Mudasir <[email protected]> |