Giter Site home page Giter Site logo

awesome-helpers's People

Contributors

adrianb93 avatar akiyamasm avatar calebporzio avatar channingdefoe avatar chapeupreto avatar cupoftea696 avatar lucasmesquitaborges avatar midnite81 avatar nullthoughts avatar nunomaduro avatar peter279k avatar repat avatar szepeviktor avatar teejay-codes avatar timacdonald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

awesome-helpers's Issues

Check if functions exist

I want to use this but I get errors where they conflict with my own implementations:

Cannot redeclare connection() (previously declared in ...vendor/calebporzio/awesome-helpers/src/helpers/connection.php:3)

As per the usual convention:

https://github.com/laravel/helpers/blob/1c3c128fa96bad2bc338eab1823fe7372e0c5328/src/helpers.php#L6

<?php
+if (! function_exists('array_add')) {
    /**
     * Add an element to an array using "dot" notation if it doesn't exist.
     *
     * @param  array  $array
     * @param  string  $key
     * @param  mixed  $value
     * @return array
     */
    function array_add($array, $key, $value)
    {
        return Arr::add($array, $key, $value);
    }
+}

I'm happy to open a PR if you'll consider it.

Backward count() compatibility after PHP 7.2

PHP 7.2 may break some projects after the change of count() function, throwing warning (futuraly will be an error). When receiving parameters that aren't array or countable objects.

I have created a helper to treat this problem, not a good practice, but for upgrading large projects it can be used temporarily.

Do you guys consider this helper a good addition for awesome-helpers?

array_combine(): Both parameters should have an equal number of elements

When I run tinker(['id', 'title', 'description', 'completed_at', 'category']);, it gives me;

   ErrorException 

  array_combine(): Both parameters should have an equal number of elements

  at vendor/illuminate/support/Collection.php:725
    721|      * @return static
    722|      */
    723|     public function combine($values)
    724|     {
  > 725|         return new static(array_combine($this->all(), $this->getArrayableItems($values)));
    726|     }
    727| 
    728|     /**
    729|      * Union the collection with the given items.

      +1 vendor frames 
  2   app/Commands/TaskList.php:38
      Illuminate\Support\Collection::combine()

  3   app/Commands/TaskList.php:81
      App\Commands\tinker()

Version info;

$ composer show | grep laravel
laravel-zero/foundation               v7.4.0          This is a mirror from illuminate/foundation.
laravel-zero/framework                v7.2.1          The Laravel Zero Framework.
laravel/tinker                        v2.3.0          Powerful REPL for the Laravel framework.
$ composer show | grep caleb  
calebporzio/awesome-helpers           v2.4.5          Helper functions I find super-duper handy
$ php -v
PHP 7.4.6 (cli) (built: May 14 2020 10:03:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies
    with Xdebug v2.9.5, Copyright (c) 2002-2020, by Derick Rethans

Left and Right Functions - Not an issue - Potential Addition

I missed having the "left" function of c#, and the right function has been super helpful for things.
On the "right" function, I have allowed a user to pass in a positive or negative value. If they pass a positive, then I multiply it by negative 1 to get the correct format.

function left($original, $characters)
{
    if (!$original || !$characters) {
        return null;
    }
    return substr($original, 0, $characters);
}

function right($original, $characters)
{
    if (!$original || !$characters) {
        return null;
    }
    if ($characters > 0) {
        $characters *= -1;
    }
    return substr($original, $characters);
}

Uses auth()

awesome-helpers uses auth() which resides in laravel/framework but that packages is not required

Please advise.

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.