LFT
  • Namespace
  • Class
  • Tree

Namespaces

  • Docoflow
    • Contracts
    • Entity
    • Facades
    • Models
    • Traits
  • Docolight
    • Agno
      • Traits
    • Container
    • Http
      • Contracts
    • Rest
      • Handler
      • Http
    • Support
      • Debug
      • Traits
  • Docotory
    • Traits
  • None

Classes

  • Docoflow\Docoflow
  • Docoflow\Entity\Group
  • Docoflow\Entity\Step
  • Docoflow\Entity\Verificator
  • Docoflow\Facades\Action
  • Docoflow\Facades\Activity
  • Docoflow\Facades\Flo
  • Docoflow\Facades\StateActivity
  • Docoflow\Flo
  • Docoflow\Models\Workflow
  • Docoflow\Models\WorkflowAction
  • Docoflow\Models\WorkflowActivity
  • Docoflow\Models\WorkflowGroups
  • Docoflow\Models\WorkflowNotification
  • Docoflow\Models\WorkflowState
  • Docoflow\Models\WorkflowStateActivity
  • Docoflow\Models\WorkflowStep
  • Docoflow\Models\WorkflowVerificator
  • Docolight
  • Docolight\Agno\AgnoModule
  • Docolight\Container\Container
  • Docolight\Http\Headers
  • Docolight\Http\JsonResponse
  • Docolight\Http\MimeResponse
  • Docolight\Http\Response
  • Docolight\Http\ResponseFactory
  • Docolight\Rest\Handler\RestfulErrorHandler
  • Docolight\Rest\Http\RestFulController
  • Docolight\Support\ActiveRecordWrapper
  • Docolight\Support\Arr
  • Docolight\Support\Carbonate
  • Docolight\Support\ClassLoader
  • Docolight\Support\Collection
  • Docolight\Support\CollectionDataProvider
  • Docolight\Support\Debug\Dumper
  • Docolight\Support\Debug\HtmlDumper
  • Docolight\Support\Facade
  • Docolight\Support\Factory
  • Docolight\Support\Fluent
  • Docolight\Support\Html
  • Docolight\Support\IterablePager
  • Docolight\Support\Repository
  • Docolight\Support\Set
  • Docolight\Support\Str
  • Docotory\Factory

Interfaces

  • Docoflow\Contracts\DocoflowContract
  • Docoflow\Contracts\ValidationStatus
  • Docolight\Http\Contracts\Arrayable

Traits

  • Docoflow\Traits\BulkValidator
  • Docoflow\Traits\Entity
  • Docoflow\Traits\HasMutator
  • Docoflow\Traits\Validable
  • Docolight\Agno\Traits\HasAssetsUrl
  • Docolight\Agno\Traits\HasAutoload
  • Docolight\Support\Traits\Macroable
  • Docotory\Traits\HasFactories

Exceptions

  • Docolight\Container\BindingResolutionException
  • Docotory\ResolvingTypeException

Functions

  • array_add
  • array_build
  • array_collapse
  • array_divide
  • array_dot
  • array_except
  • array_first
  • array_flatten
  • array_forget
  • array_get
  • array_has
  • array_last
  • array_only
  • array_pluck
  • array_pull
  • array_replace_value
  • array_set
  • array_sort
  • array_sort_recursive
  • array_where
  • cache
  • camel_case
  • class_basename
  • class_uses_recursive
  • collect
  • container
  • data_get
  • dd
  • def
  • dump
  • e
  • ends_with
  • fluent
  • get
  • head
  • input
  • last
  • object_get
  • preg_replace_sub
  • request
  • response
  • session
  • snake_case
  • starts_with
  • str_contains
  • str_finish
  • str_is
  • str_limit
  • str_random
  • str_replace_array
  • str_slug
  • studly_case
  • title_case
  • trait_uses_recursive
  • transaction
  • trimtolower
  • value
  • with
 1 <?php
 2 
 3 namespace Docolight\Support\Traits;
 4 
 5 use Closure;
 6 use BadMethodCallException;
 7 
 8 trait Macroable
 9 {
10     /**
11      * The registered string macros.
12      *
13      * @var array
14      */
15     protected static $macros = [];
16 
17     /**
18      * Register a custom macro.
19      *
20      * @param string   $name
21      * @param callable $macro
22      */
23     public static function macro($name, callable $macro)
24     {
25         static::$macros[$name] = $macro;
26     }
27 
28     /**
29      * Checks if macro is registered.
30      *
31      * @param string $name
32      *
33      * @return bool
34      */
35     public static function hasMacro($name)
36     {
37         return isset(static::$macros[$name]);
38     }
39 
40     /**
41      * Dynamically handle calls to the class.
42      *
43      * @param string $method
44      * @param array  $parameters
45      *
46      * @return mixed
47      *
48      * @throws \BadMethodCallException
49      */
50     public static function __callStatic($method, $parameters)
51     {
52         if (static::hasMacro($method)) {
53             if (static::$macros[$method] instanceof Closure) {
54                 return call_user_func_array(Closure::bind(static::$macros[$method], null, get_called_class()), $parameters);
55             } else {
56                 return call_user_func_array(static::$macros[$method], $parameters);
57             }
58         }
59 
60         throw new BadMethodCallException("Method {$method} does not exist.");
61     }
62 
63     /**
64      * Dynamically handle calls to the class.
65      *
66      * @param string $method
67      * @param array  $parameters
68      *
69      * @return mixed
70      *
71      * @throws \BadMethodCallException
72      */
73     public function __call($method, $parameters)
74     {
75         if (static::hasMacro($method)) {
76             if (static::$macros[$method] instanceof Closure) {
77                 return call_user_func_array(static::$macros[$method]->bindTo($this, get_class($this)), $parameters);
78             } else {
79                 return call_user_func_array(static::$macros[$method], $parameters);
80             }
81         }
82 
83         throw new BadMethodCallException("Method {$method} does not exist.");
84     }
85 }
86 
LFT API documentation generated by ApiGen