Coder Social home page Coder Social logo

purl's Introduction

🧾 Purl

PHP için URL oluşturma ve manipülasyon aracı.

Kurulum

🛠️ Paketi composer ile projenize dahil edin;

composer require mlevent/purl

URL Oluşturma

use Mlevent\Purl;

$url = new Purl;

$args = [
    'category' => 'bestSellers', 
    'colors' => [
        'red', 
        'blue',
        'black',
    ], 
    'sort' => 'desc',
    'page' => 2,
];

/**
 * @output
 * https://github.com/shop/?category=bestSellers&colors=red,blue,black&sort=desc&page=2
 */
echo $url->path('shop')
         ->args($args)
         ->build();
         
/**
 * @output
 * https://google.com/shop/?category=bestSellers&colors=red,blue,black&sort=desc&page=2
 */
echo $url->baseUrl('https://google.com')
         ->path('shop')
         ->args($args)
         ->build();

/**
 * @output
 * shop/?category=bestSellers&colors=red,blue,black&sort=desc&page=2
 */
echo $url->baseUrl(false)
         ->path('shop')
         ->args($args)
         ->build();

Manipülasyon

/**
 * @current
 * https://github.com/products/?colors=blue&sizes=S,M,L&sort=price&page=2
 * 
 * @output
 * https://github.com/products/?colors=blue,red,black&sort=price
 */
echo $url->args(['colors' => ['red', 'black']])
         ->deny('sizes', 'page')
         ->push();
         
/**
 * @current
 * https://github.com/products/?colors=blue&sizes=S,M,L&sort=price&page=2
 * 
 * @output
 * https://github.com/products/?colors=blue&sizes=S,M,L
 */
echo $url->allow('colors', 'sizes')
         ->push();

Metodlar

/**
 * @param  nullable|string $arg
 * @return array
 */
$url->getArgs($arg);

/**
 * @return array
 */
$url->getAllowedArgs();

/**
 * @return array
 */
$url->getDeniedArgs();

/**
 * @return  string
 * @example /category/electronics/telephone
 */
$url->getPath();

/**
 * @return  string
 * @example category
 */
$url->getPath(0);

/**
 * @param  string $arg
 * @return boolean
 */
$url->hasArg($args);

/**
 * @param  string $value
 * @return boolean
 */
$url->hasValue($value);

/**
 * @return string
 */
$url->getCurrentUrl();

purl's People

Contributors

mlevent avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.