@@ -11,11 +11,11 @@ |
||
| 11 | 11 | |
| 12 | 12 | namespace BrightNucleus\Shortcode; |
| 13 | 13 | |
| 14 | -use Assert; |
|
| 15 | -use BrightNucleus\Config\ConfigInterface; |
|
| 16 | -use BrightNucleus\Config\ConfigTrait; |
|
| 17 | -use BrightNucleus\Dependency\DependencyManagerInterface as DependencyManager; |
|
| 18 | -use BrightNucleus\Exception\DomainException; |
|
| 14 | +use Assert; |
|
| 15 | +use BrightNucleus\Config\ConfigInterface; |
|
| 16 | +use BrightNucleus\Config\ConfigTrait; |
|
| 17 | +use BrightNucleus\Dependency\DependencyManagerInterface as DependencyManager; |
|
| 18 | +use BrightNucleus\Exception\DomainException; |
|
| 19 | 19 | use BrightNucleus\Exception\RuntimeException; |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | DependencyManager $dependencies = null |
| 82 | 82 | ) {
|
| 83 | 83 | |
| 84 | - Assert\that( $shortcode_tag )->string()->notEmpty(); |
|
| 84 | + Assert\that($shortcode_tag)->string()->notEmpty(); |
|
| 85 | 85 | |
| 86 | - $this->processConfig( $config ); |
|
| 86 | + $this->processConfig($config); |
|
| 87 | 87 | |
| 88 | 88 | $this->shortcode_tag = $shortcode_tag; |
| 89 | 89 | $this->atts_parser = $atts_parser; |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | * (Not used with Shortcode class) |
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | - public function register( $args = null ) {
|
|
| 103 | - if ( ! $this->is_needed( $args ) ) {
|
|
| 102 | + public function register($args = null) {
|
|
| 103 | + if ( ! $this->is_needed($args)) {
|
|
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | - \add_shortcode( $this->get_tag(), [ $this, 'render' ] ); |
|
| 106 | + \add_shortcode($this->get_tag(), [$this, 'render']); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,14 +114,14 @@ discard block |
||
| 114 | 114 | * @param mixed $context Data about the context in which the call is made. |
| 115 | 115 | * @return boolean Whether the shortcode is needed or not. |
| 116 | 116 | */ |
| 117 | - protected function is_needed( $context = null ) {
|
|
| 117 | + protected function is_needed($context = null) {
|
|
| 118 | 118 | |
| 119 | - $is_needed = $this->hasConfigKey( 'is_needed' ) |
|
| 120 | - ? $this->getConfigKey( 'is_needed' ) |
|
| 119 | + $is_needed = $this->hasConfigKey('is_needed')
|
|
| 120 | + ? $this->getConfigKey('is_needed')
|
|
| 121 | 121 | : false; |
| 122 | 122 | |
| 123 | - if ( is_callable( $is_needed ) ) {
|
|
| 124 | - return $is_needed( $context ); |
|
| 123 | + if (is_callable($is_needed)) {
|
|
| 124 | + return $is_needed($context); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return (bool) $is_needed; |
@@ -153,22 +153,22 @@ discard block |
||
| 153 | 153 | * render. |
| 154 | 154 | * @return string The shortcode's HTML output. |
| 155 | 155 | */ |
| 156 | - public function render( $atts, $content = null, $tag = null ) {
|
|
| 157 | - $atts = $this->atts_parser->parse_atts( $atts, $this->get_tag() ); |
|
| 156 | + public function render($atts, $content = null, $tag = null) {
|
|
| 157 | + $atts = $this->atts_parser->parse_atts($atts, $this->get_tag()); |
|
| 158 | 158 | |
| 159 | - if ( $this->dependencies ) {
|
|
| 160 | - $this->dependencies->enqueue( $atts ); |
|
| 159 | + if ($this->dependencies) {
|
|
| 160 | + $this->dependencies->enqueue($atts); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( ! $this->hasConfigKey( 'view' ) ) {
|
|
| 163 | + if ( ! $this->hasConfigKey('view')) {
|
|
| 164 | 164 | return ''; |
| 165 | 165 | } |
| 166 | - $view = $this->getConfigKey( 'view' ); |
|
| 166 | + $view = $this->getConfigKey('view');
|
|
| 167 | 167 | |
| 168 | - Assert\that( $view )->string()->notEmpty()->file(); |
|
| 168 | + Assert\that($view)->string()->notEmpty()->file(); |
|
| 169 | 169 | |
| 170 | 170 | ob_start(); |
| 171 | - include( $this->config['view'] ); |
|
| 171 | + include($this->config['view']); |
|
| 172 | 172 | |
| 173 | 173 | return ob_get_clean(); |
| 174 | 174 | } |
@@ -11,9 +11,9 @@ |
||
| 11 | 11 | |
| 12 | 12 | namespace BrightNucleus\Shortcode; |
| 13 | 13 | |
| 14 | -use BrightNucleus\Config\ConfigInterface; |
|
| 15 | -use BrightNucleus\Config\ConfigTrait; |
|
| 16 | -use BrightNucleus\Dependency\DependencyManagerInterface as DependencyManager; |
|
| 14 | +use BrightNucleus\Config\ConfigInterface; |
|
| 15 | +use BrightNucleus\Config\ConfigTrait; |
|
| 16 | +use BrightNucleus\Dependency\DependencyManagerInterface as DependencyManager; |
|
| 17 | 17 | use BrightNucleus\Exception\RuntimeException; |
| 18 | 18 | |
| 19 | 19 | /** |