Coder Social home page Coder Social logo

phelpers's Introduction

PHelPers

Latest Stable Version Latest Unstable Version Test Status

Maintenance Packagist PHP from Packagist composer.lock available license


A collection of random quality of life functions for PHP – a sort of toolbox.

Requirements

There are not many requirements for this library; infact, the only true requirement is PHP, but if you plan to contribute, having GNU Make installed will make for nicer dev experience than without.

Requirement Version
PHP ^7.2
Make (dev only) ^3.81

Installation

Nothing much to do but require the library in your own project's composer dependencies!

$ composer require jordanbrauer/phelpers

Once you have the library installed, head over to the list of available functions to shop around.

Development

  1. Start by cloning the project to your own machine.
  2. Move yourself into the newly cloned repository directory.
  3. Run make to install dev dependencies.
$ git clone https://github.com/jordanbrauer/phelpers.git \
    && cd ./phelpers \
    && make vendor \
    && make;

Usage

As mentioned in the Requirements section of this document, having GNU Make installed on your system will make for nice development experience while contributing. To get started, run Make without any targets or arguments:

$ make

And you will be greeted with the list of targets for this project!

Usage:
  make [target] [arg="val"...]

Targets:
  analysis        Run analysis
  help            Show this help message
  repl            Start a REPL instance and interact with the library
  test            Run tests
  vendor          Install vendor dependencies

Try Me

If you're not sure that this library is right for you, can "try before you buy". Start by installing the project for development, and then simply boot up the REPL packaged with the repository!

$ make repl

Using the functions is easy – just make sure that you preface your functions with the projects namespace first.

λ Phelpers\is_console() # true
λ Phelpers\is_web()     # false

Available Functions

Array Functions

  • append
  • array_make
  • generate
  • head
  • is_associative
  • only
  • prepend
  • tail
  • wrap

Number Functions

  • between
  • ordinal
  • random_float

Object Functions

N/A

String Functions

  • append
  • camel_case
  • class_basename
  • kebab_case
  • pascal_case
  • prepend
  • snake_case
  • str_random

Miscellaneous Functions

  • blank
  • retry
  • swap
  • tap
  • transform
  • value
  • with

phelpers's People

Contributors

jordanbrauer avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

phelpers's Issues

implement function to easily create paths with

basically, this will handle cross platform directories very nicely for the user.

As an example, something like this

path(__DIR__, 'vendor', 'autoload.php');

abstracts away the DIRECTORY_SEPARATOR and ensures compatibility between any OS running PHP.

as opposed to how it's usually done

__DIR__ . 'vendor/autoload.php';

test windows in CI workflow

The path function test needs a Windows test

- windows OS drive detection for absolute paths → Unix and other non-Windows or DOS based OSs do not use drive letter assignment

Tests:  2 skipped, 160 passed

the `get` function cannot read data from objects which implement magic properties & methods

The specific place is when we actually check for the existence of a property on the object. In this case we just need to add an additional condition the check using isset.

if ($isObject and (isset($subject, $path) or \property_exists($subject, $path))) {
    # ...
}

isset is first in the existence check as it is the fastest (being a language construct, not a function call) and if true will short circuit the calls to property_exists. In other words, property_exists should be our plan B and isset should be first line of defence.

collapse function needs to be fleshed out

  WARN  Tests\Unit\CollapseTest
  - it collapses multi-dimensional arrays into flat arrays with dot notation keys → not sure how this function should even behave yet...

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.