File: D:/HostingSpaces/SBogers10/douven.komma.pro/app/KommaApp/Core/WildcardController.php
<?php
/**
* Created by PhpStorm.
* User: julesgraus
* Date: 16/02/2018
* Time: 15:27
*/
namespace App\KommaApp\Core;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
abstract class WildcardController extends Controller
{
protected $resolvesWildCardForPath = '';
/**
* Returns true if the specified path is resolved by this thing or false if not
*
* @param string $path
* @return bool
*/
public function resolvesWildcardPath(string $path): bool
{
$pathParts = explode('/', $path);
$pathPartsCount = count($pathParts);
$resolvesWildcardForPathParts = explode('/', $this->resolvesWildCardForPath);
$resolvesWildcardForPathPartsCount = count($resolvesWildcardForPathParts);
if($resolvesWildcardForPathPartsCount > $pathPartsCount) return false;
for($index = 0; $index < $resolvesWildcardForPathPartsCount; $index++)
{
if($resolvesWildcardForPathParts[$index] != $pathParts[$index]) return false;
}
return true;
}
/**
* Shows a specific resource
*
* @param string $language
* @param string $wildCard
* @return mixed
*/
abstract public function wildcardShow(string $language, string $wildCard);
/**
* Show overview of resources
*
* @param Request $request
* @return mixed
*/
abstract public function wildcardIndex(Request $request);
}