| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types=1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | /** | 
| 6 | 6 | * Wrapper for BladeOne with HTML enabled | 
| @@ -46,19 +46,19 @@ discard block | ||
| 46 | 46 | * @param string $compiled_path If null then it uses (caller_folder)/compiles | 
| 47 | 47 | * @param int $mode =[BladeOne::MODE_AUTO,BladeOne::MODE_DEBUG,BladeOne::MODE_FAST,BladeOne::MODE_SLOW][$i] | 
| 48 | 48 | */ | 
| 49 | -	public function __construct( $template_path = null, $compiled_path = null, $mode = 0 ) { | |
| 50 | - parent::__construct( $template_path, $compiled_path, $mode ); | |
| 49 | +	public function __construct($template_path = null, $compiled_path = null, $mode = 0) { | |
| 50 | + parent::__construct($template_path, $compiled_path, $mode); | |
| 51 | 51 | |
| 52 | 52 | // Add the viewModel directive. | 
| 53 | - $this->directiveRT( 'viewModel', fn( $expression ) => $this->view_model( $expression, true ) ); | |
| 53 | +		$this->directiveRT('viewModel', fn($expression) => $this->view_model($expression, true)); | |
| 54 | 54 | |
| 55 | 55 | // Add the component directive. | 
| 56 | - $this->directiveRT( 'viewComponent', fn( $expression ) => $this->component( $expression, true ) ); | |
| 56 | +		$this->directiveRT('viewComponent', fn($expression) => $this->component($expression, true)); | |
| 57 | 57 | |
| 58 | 58 | // Add the WP_Nonce directive. | 
| 59 | 59 | $this->directiveRT( | 
| 60 | 60 | 'nonce', | 
| 61 | -			function( string $action, ?string $field = null, bool $inc_referer = true ): void { | |
| 61 | +			function(string $action, ?string $field = null, bool $inc_referer = true): void { | |
| 62 | 62 | \wp_nonce_field( | 
| 63 | 63 | $action, | 
| 64 | 64 | $field ?? '_pcnonce', | 
| @@ -69,7 +69,7 @@ discard block | ||
| 69 | 69 | ); | 
| 70 | 70 | |
| 71 | 71 | // Allow other plugins to add their own directives. | 
| 72 | - \do_action( self::SETUP_CONFIG, $this ); | |
| 72 | + \do_action(self::SETUP_CONFIG, $this); | |
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | 75 | /** | 
| @@ -93,14 +93,14 @@ discard block | ||
| 93 | 93 | * @param string $esc_function | 
| 94 | 94 | * @return void | 
| 95 | 95 | */ | 
| 96 | -	public function set_esc_function( string $esc_function ): void { | |
| 96 | +	public function set_esc_function(string $esc_function): void { | |
| 97 | 97 | // Throw exception if not a valid callable. | 
| 98 | -		if ( ! \is_callable( $esc_function ) ) { | |
| 99 | - throw new \InvalidArgumentException( 'Invalid esc function provided.' ); | |
| 98 | +		if ( ! \is_callable($esc_function)) { | |
| 99 | +			throw new \InvalidArgumentException('Invalid esc function provided.'); | |
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | 102 | static::$esc_function = $esc_function; | 
| 103 | - $this->echoFormat = sprintf( '\\%s(%%s)', $esc_function ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | |
| 103 | +		$this->echoFormat     = sprintf('\\%s(%%s)', $esc_function); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | |
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | 106 | /** | 
| @@ -118,17 +118,17 @@ discard block | ||
| 118 | 118 | * @param int|float|string|null|mixed[]|object $value | 
| 119 | 119 | * @return string | 
| 120 | 120 | */ | 
| 121 | -	public static function e( $value ): string { | |
| 122 | -		if ( \is_null( $value ) ) { | |
| 121 | +	public static function e($value): string { | |
| 122 | +		if (\is_null($value)) { | |
| 123 | 123 | return ''; | 
| 124 | 124 | } | 
| 125 | -		if ( \is_array( $value ) || \is_object( $value ) ) { | |
| 126 | - return \call_user_func( static::$esc_function, \print_r( $value, true ) );//phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r | |
| 125 | +		if (\is_array($value) || \is_object($value)) { | |
| 126 | + return \call_user_func(static::$esc_function, \print_r($value, true)); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r | |
| 127 | 127 | } | 
| 128 | -		if ( \is_numeric( $value ) ) { | |
| 128 | +		if (\is_numeric($value)) { | |
| 129 | 129 | $value = (string) $value; | 
| 130 | 130 | } | 
| 131 | - return \call_user_func( static::$esc_function, $value ); | |
| 131 | + return \call_user_func(static::$esc_function, $value); | |
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | 134 | /** | 
| @@ -138,11 +138,11 @@ discard block | ||
| 138 | 138 | * @param bool $print | 
| 139 | 139 | * @return string|void | 
| 140 | 140 | */ | 
| 141 | -	public function component( Component $component, bool $print = true ) { | |
| 141 | +	public function component(Component $component, bool $print = true) { | |
| 142 | 142 | /** @var View */ | 
| 143 | 143 | $view = App::view(); | 
| 144 | 144 | |
| 145 | - return $view->component( $component, $print ); | |
| 145 | + return $view->component($component, $print); | |
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | 148 | /** | 
| @@ -152,11 +152,11 @@ discard block | ||
| 152 | 152 | * @param bool $print Print or Return the HTML | 
| 153 | 153 | * @return string|void | 
| 154 | 154 | */ | 
| 155 | -	public function view_model( View_Model $view_model, bool $print = true ) { | |
| 155 | +	public function view_model(View_Model $view_model, bool $print = true) { | |
| 156 | 156 | /** @var View */ | 
| 157 | 157 | $view = App::view(); | 
| 158 | 158 | |
| 159 | - return $view->view_model( $view_model, $print ); | |
| 159 | + return $view->view_model($view_model, $print); | |
| 160 | 160 | } | 
| 161 | 161 | |
| 162 | 162 | /** | 
| @@ -165,13 +165,13 @@ discard block | ||
| 165 | 165 | * @param string $expression | 
| 166 | 166 | * @return string | 
| 167 | 167 | */ | 
| 168 | -	protected function compileAuth( $expression = '' ): string { | |
| 169 | - $role = $this->stripParentheses( $expression ); | |
| 170 | -		if ( $role === '' ) { | |
| 171 | - return $this->phpTag . 'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; | |
| 168 | +	protected function compileAuth($expression = ''): string { | |
| 169 | + $role = $this->stripParentheses($expression); | |
| 170 | +		if ($role === '') { | |
| 171 | + return $this->phpTag.'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | - return $this->phpTag . "if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; | |
| 174 | + return $this->phpTag."if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; | |
| 175 | 175 | } | 
| 176 | 176 | |
| 177 | 177 | /** | 
| @@ -180,13 +180,13 @@ discard block | ||
| 180 | 180 | * @param string $expression | 
| 181 | 181 | * @return string | 
| 182 | 182 | */ | 
| 183 | -	protected function compileElseAuth( $expression = '' ): string { | |
| 184 | - $role = $this->stripParentheses( $expression ); | |
| 185 | -		if ( $role === '' ) { | |
| 186 | - return $this->phpTag . 'else: ?>'; | |
| 183 | +	protected function compileElseAuth($expression = ''): string { | |
| 184 | + $role = $this->stripParentheses($expression); | |
| 185 | +		if ($role === '') { | |
| 186 | + return $this->phpTag.'else: ?>'; | |
| 187 | 187 | } | 
| 188 | 188 | |
| 189 | - return $this->phpTag . "elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; | |
| 189 | + return $this->phpTag."elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; | |
| 190 | 190 | } | 
| 191 | 191 | |
| 192 | 192 | /** | 
| @@ -195,18 +195,18 @@ discard block | ||
| 195 | 195 | * @param string|null $expression | 
| 196 | 196 | * @return string | 
| 197 | 197 | */ | 
| 198 | -	protected function compileGuest( $expression = null ): string { | |
| 198 | +	protected function compileGuest($expression = null): string { | |
| 199 | 199 | |
| 200 | -		if ( $expression === null ) { | |
| 201 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; | |
| 200 | +		if ($expression === null) { | |
| 201 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; | |
| 202 | 202 | } | 
| 203 | 203 | |
| 204 | - $role = $this->stripParentheses( $expression ); | |
| 205 | -		if ( $role === '' ) { | |
| 206 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; | |
| 204 | + $role = $this->stripParentheses($expression); | |
| 205 | +		if ($role === '') { | |
| 206 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; | |
| 207 | 207 | } | 
| 208 | 208 | |
| 209 | - return $this->phpTag . "if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; | |
| 209 | + return $this->phpTag."if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; | |
| 210 | 210 | } | 
| 211 | 211 | |
| 212 | 212 | /** | 
| @@ -215,13 +215,13 @@ discard block | ||
| 215 | 215 | * @param string|null $expression | 
| 216 | 216 | * @return string | 
| 217 | 217 | */ | 
| 218 | -	protected function compileElseGuest( $expression ): string { | |
| 219 | - $role = $this->stripParentheses( $expression ); | |
| 220 | -		if ( $role === '' ) { | |
| 221 | - return $this->phpTag . 'else: ?>'; | |
| 218 | +	protected function compileElseGuest($expression): string { | |
| 219 | + $role = $this->stripParentheses($expression); | |
| 220 | +		if ($role === '') { | |
| 221 | + return $this->phpTag.'else: ?>'; | |
| 222 | 222 | } | 
| 223 | 223 | |
| 224 | - return $this->phpTag . "elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; | |
| 224 | + return $this->phpTag."elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; | |
| 225 | 225 | } | 
| 226 | 226 | |
| 227 | 227 | } |