PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / 0.0.1
Code Engine – PHP Snippets, AI Functions & Automation for WordPress v0.0.1
0.5.7 0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.9 0.4.8 0.4.7 0.4.6 trunk 0.0.1 0.0.2 0.2.8 0.2.9 0.3.0 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 All 33 releases
code-engine / classes / models / cdegn_function.php

cdegn_function.php in Code Engine – PHP Snippets, AI Functions & Automation for WordPress 0.0.1, at classes/models/cdegn_function.php

56 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Model class for handling the option of cdegn_functions
4 */
5 final class Meow_CDEGN_Models_Cdegn_Function implements JsonSerializable {
6
7 /** @var int */
8 private $snippet_id;
9
10 /** @var string */
11 private $snippet_src;
12
13 /** @var string */
14 private $name;
15
16 /** @var string */
17 private $desc;
18
19 /** @var array */
20 private $args;
21
22 public function __construct( array $item ) {
23 $this->snippet_id = $item['snippet_id'];
24 $this->snippet_src = $item['snippet_src'];
25 $this->name = $item['name'];
26 $this->desc = $item['desc'];
27 $this->args = array_map( function( $arg_variable, $arg_info ) {
28 return new Meow_CDEGN_Models_Cdegn_Function_Arg( $arg_variable, $arg_info );
29 }, array_keys( $item['args'] ), $item['args'] );
30 }
31
32 public function snippet_id(): int {
33 return $this->snippet_id;
34 }
35
36 public function snippet_src(): string {
37 return $this->snippet_src;
38 }
39
40 public function overview(): string {
41 $args = array_map( function( $arg ) { return $arg->format(); }, $this->args );
42 $overview = sprintf( 'function %s( %s )', $this->name, implode( ', ', $args ) );
43 return $overview;
44 }
45
46 public function jsonSerialize(): mixed {
47 return [
48 'snippetId' => $this->snippet_id,
49 'snippetSrc' => $this->snippet_src,
50 'name' => $this->name,
51 'desc' => $this->desc,
52 'args' => $this->args,
53 ];
54 }
55 }
56