3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Best Buy SDK * * High level PHP client for the Best Buy API */ namespace BestBuy; use BestBuy\Exception\AuthorizationException; use BestBuy\Exception\InvalidArgumentException; use BestBuy\Exception\ServiceException; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; /** * The main client */ class Client implements LoggerAwareInterface { /** * The endpoint for the most popular viewed products */ const RECOMMENDATIONS_MOSTVIEWED = 'mostViewed'; /** * The endpoint for the most trending viewed products */ const RECOMMENDATIONS_TRENDING = 'trendingViewed'; /** * The endpoint for also viewed products (given an input product) */ const RECOMMENDATIONS_ALSOVIEWED = 'alsoViewed'; /** * The endpoint for similar products (given an input product) */ const RECOMMENDATIONS_SIMILAR = 'similar'; /** * The beta URL */ const URL_BETA = 'https://api.bestbuy.com/beta'; /** * The v1 URL */ const URL_V1 = 'https://api.bestbuy.com/v1'; /** * The configuration for the class * * # Available keys: * * `key` - string - Your Best Buy Developer API Key * * `debug` - bool - Whether to log debug information * * `curl_options` - array - An array of options to be passed into {@see curl_setopt_array} * * `associative` - bool - Whether the response should be decoded to an associative array (default to {@see StdClass}) * * @var array */ protected $config = [ 'key' => '', 'debug' => false, 'curl_options' => [ CURLOPT_RETURNTRANSFER => false, CURLOPT_HTTPHEADER => [ 'User-Agent' => 'bestbuy-sdk-php/1.0.0;php' ] ], 'associative' => false ]; /** * The logger to log to in debug mode * * @var LoggerInterface */ protected $logger; /** * Creates new instance * * @param mixed $options * If array: Merge options into client config * If string: Used as API Key * If null: Look for $_SERVER['BBY_API_KEY'] */ public function __construct($options = null) { // If we didn't get anything, but the key is a server variable, use that // Or the `$options` is a string, use that as a key // Or the `$options` is an array, merge that into the default options if (!$options && isset($_SERVER['BBY_API_KEY'])) { $this->config['key'] = $_SERVER['BBY_API_KEY']; } else if (is_string($options)) { $this->config['key'] = $options; } else if (is_array($options)) { if (isset($options['key'])) { $this->config['key'] = $options['key']; } $this->config = array_merge($this->config, $options); } } /** * Retrieve availability of products in stores based on the criteria provided * * @param int|int[]|string $skus A SKU or SKUs to look for, or a valid product query * @param int|int[]|string $stores A Store # or Store #s to look for, or a valid store query * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass * @throws ServiceException */ public function availability($skus, $stores, array $responseConfig = []) { // if it's a single SKU (either int or only digits), make it to an array (for the next block) if (is_int($skus) || ctype_digit($skus)) { $skus = [(int)$skus]; } if (is_array($skus)) { $skus = 'sku in(' . implode(',', $skus) . ')'; } // if it's a single store (either int or only digits), make it to an array (for the next block) if (is_int($stores) || ctype_digit($stores)) { $stores = [(int)$stores]; } if (is_array($stores)) { $stores = 'storeId in(' . implode(',', $stores) . ')'; } return $this->doRequest( self::URL_V1, "/products({$skus})+stores({$stores})", $responseConfig ); } /** * Retrieve categories based on the criteria provided * * @param string $search A category ID or valid query * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass */ public function categories($search = '', array $responseConfig = []) { return $this->simpleEndpoint('categories', $search, $responseConfig); } /** * Retrieve open box products based on the criteria provided * * @param mixed $search int = single SKU; int[] = multiple SKUs; string = query; null = all open box * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass * @throws ServiceException */ public function openBox($search = '', array $responseConfig = []) { // If the search is an int or string of digits, load the results for that SKU // Or the search is an array of SKUs, load the results for those SKUs // Or the search is a query (categoryPath.id=*******), load the results in that category // Else just get all open box products if (is_int($search) || ctype_digit($search)) { $path = "/products/{$search}/openBox"; } else if (is_array($search)) { $skus = implode(',', $search); $path = "/products/openBox(sku in({$skus}))"; } else if ($search) { $path = "/products/openBox({$search})"; } else { $path = '/products/openBox'; } return $this->doRequest( self::URL_BETA, $path, $responseConfig ); } /** * Retrieve products based on the criteria provided * * @param string|int $search A product SKU or valid query * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass */ public function products($search = '', array $responseConfig = []) { return $this->simpleEndpoint('products', $search, $responseConfig); } /** * Retrieve recommendations based on the criteria provided * * If using {@see BestBuy\Client::RECOMMENDATIONS_SIMILAR} or {@see BestBuy\Client::RECOMMENDATIONS_ALSOVIEWED} * you MUST pass in a SKU. * * @param string $type One of `\BestBuy\Client::RECOMMENDATIONS_*` * @param string|int $categoryIdOrSku Either a category ID for _TRENDING & _MOSTVIEWED or a SKU for _SIMILAR & _ALSOVIEWED * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass * @throws InvalidArgumentException * @throws ServiceException */ public function recommendations($type, $categoryIdOrSku = null, array $responseConfig = []) { if ($type == self::RECOMMENDATIONS_TRENDING || $type == self::RECOMMENDATIONS_MOSTVIEWED) { // Trending & Most viewed work either globally or on a category level, hence the category ID is optional $search = $categoryIdOrSku !== null ? "(categoryId={$categoryIdOrSku})" : ''; $path = "/products/{$type}{$search}"; } else if ($type == self::RECOMMENDATIONS_ALSOVIEWED || $type == self::RECOMMENDATIONS_SIMILAR) { // Similar & Also viewed work on the SKU level, hence the SKU is required if ($categoryIdOrSku === null) { throw new InvalidArgumentException( 'For `Client::RECOMMENDATIONS_SIMILAR` & `Client::RECOMMENDATIONS_ALSOVIEWED`, a SKU is required' ); } $path = "/products/{$categoryIdOrSku}/{$type}"; } else { // The argument passed in isn't a valid recommendation type throw new InvalidArgumentException('`$type` must be one of `Client::RECOMMENDATIONS_*`'); } return $this->doRequest( self::URL_BETA, $path, $responseConfig ); } /** * Retrieve reviews based on the criteria provided * * @param string|int $search A review ID or valid query * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass */ public function reviews($search = '', array $responseConfig = []) { return $this->simpleEndpoint('reviews', $search, $responseConfig); } /** * Sets a logger instance on the object * * @codeCoverageIgnore * * @param LoggerInterface $logger * @return null */ public function setLogger(LoggerInterface $logger) { $this->logger = $logger; } /** * Retrieve stores based on the criteria provided * * @param string|int $search A store ID or valid query * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass */ public function stores($search = '', array $responseConfig = []) { return $this->simpleEndpoint('stores', $search, $responseConfig); } /** * Builds the URL to make the request against * * @param string $root The Root URL to use ({@see BestBuy\Client::URL_V1} or {@see BestBuy\Client::URL_BETA} * @param string $path The path for the endpoint + resources * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass * @throws AuthorizationException */ protected function buildUrl($root, $path, array $responseConfig = []) { // Verify the client has a key if (!$this->config['key']) { throw new AuthorizationException( 'A Best Buy developer API key is required. Register for one at ' . 'developer.bestbuy.com, call new `\BestBuy\Client(YOUR_API_KEY)`, or ' . 'specify a BBY_API_KEY system environment variable.' ); } $responseConfig['apiKey'] = $this->config['key']; // If we're loading just a single resource ({sku}.json), remove the format from the querystring--it'll 400 if (!preg_match('/\.json$/', $path)) { $responseConfig['format'] = 'json'; } $querystring = http_build_query($responseConfig); // replace whitespace with url-encoded whitespace return preg_replace('/\s+/', '%20', "{$root}{$path}?{$querystring}"); } /** * Executes a request & returns the response * * @param string $root The Root URL to use ({@see BestBuy\Client::URL_V1} or {@see BestBuy\Client::URL_BETA} * @param string $path The path for the endpoint + resources * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass * @throws AuthorizationException * @throws ServiceException */ protected function doRequest($root, $path, array $responseConfig = []) { // Set up the curl request $handle = curl_init($this->buildUrl($root, $path, $responseConfig)); curl_setopt_array( $handle, // using `+` to retain indices [ CURLOPT_FAILONERROR => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true ] + $this->config['curl_options'] ); // Get the response $response = curl_exec($handle); // Log if needed if ($this->config['debug'] && $this->logger) { $this->logger->info(var_export(curl_getinfo($handle), true)); } // Check for errors & close the handle $curlErrorNumber = curl_errno($handle); $curlErrorText = curl_error($handle); curl_close($handle); // If we have an error code, log if needed & bail out if ($curlErrorNumber) { if ($this->logger) { $this->logger->error($curlErrorText); } throw new ServiceException('An error occurred when communicating with the service'); } // Return the response in the configured format return json_decode($response, $this->config['associative']); } /** * Handles standard endpoints (products, stores, categories, reviews) * * @param string $endpoint The base endpoint to retrieve data from * @param string|int $search The identifier of an object or a valid query * @param array $responseConfig The additional filters to apply to the result set (pagination, view, sort, etc.) * @return array|\StdClass * @throws ServiceException */ protected function simpleEndpoint($endpoint, $search, array $responseConfig = []) { // If it's an integer (or a string that's only digits), or a category id, load the resource directly // Or we have a valid query, load the result of that query // Else load all resources if (is_int($search) || ctype_digit($search) || preg_match('/^(cat|pcmcat|abcat)\d+$/', $search)) { $path = "/{$endpoint}/{$search}.json"; } else if ($search) { $path = "/{$endpoint}({$search})"; } else { $path = "/{$endpoint}"; } return $this->doRequest( self::URL_V1, $path, $responseConfig ); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bT8JG
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_CLASS                                            'bestbuy%5Cclient'
  382     1      > RETURN                                                   1

Class BestBuy\Client:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 39
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 39
Branch analysis from position: 6
filename:       /in/bT8JG
function name:  __construct
number of ops:  40
compiled vars:  !0 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   89     0  E >   RECV_INIT                                        !0      null
   94     1        BOOL_NOT                                         ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->6
          3    >   FETCH_IS                                         ~2      '_SERVER'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      ~2, 'BBY_API_KEY'
          5        BOOL                                             ~1      ~3
          6    > > JMPZ                                                     ~1, ->13
   95     7    >   FETCH_R                      global              ~6      '_SERVER'
          8        FETCH_DIM_R                                      ~7      ~6, 'BBY_API_KEY'
          9        FETCH_OBJ_W                                      $4      'config'
         10        ASSIGN_DIM                                               $4, 'key'
         11        OP_DATA                                                  ~7
         12      > JMP                                                      ->39
   96    13    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_string'
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $8      
         16      > JMPZ                                                     $8, ->21
   97    17    >   FETCH_OBJ_W                                      $9      'config'
         18        ASSIGN_DIM                                               $9, 'key'
         19        OP_DATA                                                  !0
         20      > JMP                                                      ->39
   98    21    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_array'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0  $11     
         24      > JMPZ                                                     $11, ->39
   99    25    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'key'
         26      > JMPZ                                                     ~12, ->31
  100    27    >   FETCH_DIM_R                                      ~15     !0, 'key'
         28        FETCH_OBJ_W                                      $13     'config'
         29        ASSIGN_DIM                                               $13, 'key'
         30        OP_DATA                                                  ~15
  103    31    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Carray_merge'
         32        CHECK_FUNC_ARG                                           
         33        FETCH_OBJ_FUNC_ARG                               $17     'config'
         34        SEND_FUNC_ARG                                            $17
         35        SEND_VAR_EX                                              !0
         36        DO_FCALL                                      0  $18     
         37        ASSIGN_OBJ                                               'config'
         38        OP_DATA                                                  $18
  105    39    > > RETURN                                                   null

End of function __construct

Function availability:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
2 jumps found. (Code = 47) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 49
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 38
Branch analysis from position: 34
Branch analysis from position: 26
Branch analysis from position: 15
Branch analysis from position: 11
filename:       /in/bT8JG
function name:  availability
number of ops:  62
compiled vars:  !0 = $skus, !1 = $stores, !2 = $responseConfig
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  116     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
  119     3        INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_int'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $3      
          6      > JMPNZ_EX                                         ~4      $3, ->11
          7    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cctype_digit'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $5      
         10        BOOL                                             ~4      $5
         11    > > JMPZ                                                     ~4, ->15
  120    12    >   CAST                                          4  ~6      !0
         13        INIT_ARRAY                                       ~7      ~6
         14        ASSIGN                                                   !0, ~7
  122    15    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_array'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $9      
         18      > JMPZ                                                     $9, ->26
  123    19    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cimplode'
         20        SEND_VAL_EX                                              '%2C'
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0  $10     
         23        CONCAT                                           ~11     'sku+in%28', $10
         24        CONCAT                                           ~12     ~11, '%29'
         25        ASSIGN                                                   !0, ~12
  127    26    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_int'
         27        SEND_VAR_EX                                              !1
         28        DO_FCALL                                      0  $14     
         29      > JMPNZ_EX                                         ~15     $14, ->34
         30    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cctype_digit'
         31        SEND_VAR_EX                                              !1
         32        DO_FCALL                                      0  $16     
         33        BOOL                                             ~15     $16
         34    > > JMPZ                                                     ~15, ->38
  128    35    >   CAST                                          4  ~17     !1
         36        INIT_ARRAY                                       ~18     ~17
         37        ASSIGN                                                   !1, ~18
  130    38    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_array'
         39        SEND_VAR_EX                                              !1
         40        DO_FCALL                                      0  $20     
         41      > JMPZ                                                     $20, ->49
  131    42    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cimplode'
         43        SEND_VAL_EX                                              '%2C'
         44        SEND_VAR_EX                                              !1
         45        DO_FCALL                                      0  $21     
         46        CONCAT                                           ~22     'storeId+in%28', $21
         47        CONCAT                                           ~23     ~22, '%29'
         48        ASSIGN                                                   !1, ~23
  134    49    >   INIT_METHOD_CALL                                         'doRequest'
  135    50        FETCH_CLASS_CONSTANT                             ~25     'URL_V1'
         51        SEND_VAL_EX                                              ~25
  136    52        ROPE_INIT                                     5  ~27     '%2Fproducts%28'
         53        ROPE_ADD                                      1  ~27     ~27, !0
         54        ROPE_ADD                                      2  ~27     ~27, '%29%2Bstores%28'
         55        ROPE_ADD                                      3  ~27     ~27, !1
         56        ROPE_END                                      4  ~26     ~27, '%29'
         57        SEND_VAL_EX                                              ~26
  135    58        SEND_VAR_EX                                              !2
         59        DO_FCALL                                      0  $30     
         60      > RETURN                                                   $30
  139    61*     > RETURN                                                   null

End of function availability

Function categories:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bT8JG
function name:  categories
number of ops:  9
compiled vars:  !0 = $search, !1 = $responseConfig
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  148     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      <array>
  150     2        INIT_METHOD_CALL                                         'simpleEndpoint'
          3        SEND_VAL_EX                                              'categories'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
  151     8*     > RETURN                                                   null

End of function categories

Function openbox:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/bT8JG
function name:  openBox
number of ops:  45
compiled vars:  !0 = $search, !1 = $responseConfig, !2 = $path, !3 = $skus
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  161     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      <array>
  167     2        INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_int'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $4      
          5      > JMPNZ_EX                                         ~5      $4, ->10
          6    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cctype_digit'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $6      
          9        BOOL                                             ~5      $6
         10    > > JMPZ                                                     ~5, ->16
  168    11    >   ROPE_INIT                                     3  ~8      '%2Fproducts%2F'
         12        ROPE_ADD                                      1  ~8      ~8, !0
         13        ROPE_END                                      2  ~7      ~8, '%2FopenBox'
         14        ASSIGN                                                   !2, ~7
         15      > JMP                                                      ->37
  169    16    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cis_array'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $11     
         19      > JMPZ                                                     $11, ->30
  170    20    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cimplode'
         21        SEND_VAL_EX                                              '%2C'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0  $12     
         24        ASSIGN                                                   !3, $12
  171    25        ROPE_INIT                                     3  ~15     '%2Fproducts%2FopenBox%28sku+in%28'
         26        ROPE_ADD                                      1  ~15     ~15, !3
         27        ROPE_END                                      2  ~14     ~15, '%29%29'
         28        ASSIGN                                                   !2, ~14
         29      > JMP                                                      ->37
  172    30    > > JMPZ                                                     !0, ->36
  173    31    >   ROPE_INIT                                     3  ~19     '%2Fproducts%2FopenBox%28'
         32        ROPE_ADD                                      1  ~19     ~19, !0
         33        ROPE_END                                      2  ~18     ~19, '%29'
         34        ASSIGN                                                   !2, ~18
         35      > JMP                                                      ->37
  175    36    >   ASSIGN                                                   !2, '%2Fproducts%2FopenBox'
  178    37    >   INIT_METHOD_CALL                                         'doRequest'
  179    38        FETCH_CLASS_CONSTANT                             ~23     'URL_BETA'
         39        SEND_VAL_EX                                              ~23
         40        SEND_VAR_EX                                              !2
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0  $24     
         43      > RETURN                                                   $24
  183    44*     > RETURN                                                   null

End of function openbox

Function products:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bT8JG
function name:  products
number of ops:  9
compiled vars:  !0 = $search, !1 = $responseConfig
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  192     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      <array>
  194     2        INIT_METHOD_CALL                                         'simpleEndpoint'
          3        SEND_VAL_EX                                              'products'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
  195     8*     > RETURN                                                   null

End of function products

Function recommendations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 24
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 43
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 37
Branch analysis from position: 33
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 43
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 9
filename:       /in/bT8JG
function name:  recommendations
number of ops:  55
compiled vars:  !0 = $type, !1 = $categoryIdOrSku, !2 = $responseConfig, !3 = $search, !4 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  210     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      <array>
  212     3        FETCH_CLASS_CONSTANT                             ~5      'RECOMMENDATIONS_TRENDING'
          4        IS_EQUAL                                         ~6      !0, ~5
          5      > JMPNZ_EX                                         ~6      ~6, ->9
          6    >   FETCH_CLASS_CONSTANT                             ~7      'RECOMMENDATIONS_MOSTVIEWED'
          7        IS_EQUAL                                         ~8      !0, ~7
          8        BOOL                                             ~6      ~8
          9    > > JMPZ                                                     ~6, ->24
  214    10    >   TYPE_CHECK                                  1020          !1
         11      > JMPZ                                                     ~9, ->17
         12    >   ROPE_INIT                                     3  ~11     '%28categoryId%3D'
         13        ROPE_ADD                                      1  ~11     ~11, !1
         14        ROPE_END                                      2  ~10     ~11, '%29'
         15        QM_ASSIGN                                        ~13     ~10
         16      > JMP                                                      ->18
         17    >   QM_ASSIGN                                        ~13     ''
         18    >   ASSIGN                                                   !3, ~13
  215    19        ROPE_INIT                                     3  ~16     '%2Fproducts%2F'
         20        ROPE_ADD                                      1  ~16     ~16, !0
         21        ROPE_END                                      2  ~15     ~16, !3
         22        ASSIGN                                                   !4, ~15
         23      > JMP                                                      ->47
  216    24    >   FETCH_CLASS_CONSTANT                             ~19     'RECOMMENDATIONS_ALSOVIEWED'
         25        IS_EQUAL                                         ~20     !0, ~19
         26      > JMPNZ_EX                                         ~20     ~20, ->30
         27    >   FETCH_CLASS_CONSTANT                             ~21     'RECOMMENDATIONS_SIMILAR'
         28        IS_EQUAL                                         ~22     !0, ~21
         29        BOOL                                             ~20     ~22
         30    > > JMPZ                                                     ~20, ->43
  218    31    >   TYPE_CHECK                                    2          !1
         32      > JMPZ                                                     ~23, ->37
  219    33    >   NEW                                              $24     'BestBuy%5CException%5CInvalidArgumentException'
  220    34        SEND_VAL_EX                                              'For+%60Client%3A%3ARECOMMENDATIONS_SIMILAR%60+%26+%60Client%3A%3ARECOMMENDATIONS_ALSOVIEWED%60%2C+a+SKU+is+required'
         35        DO_FCALL                                      0          
         36      > THROW                                         0          $24
  223    37    >   ROPE_INIT                                     4  ~27     '%2Fproducts%2F'
         38        ROPE_ADD                                      1  ~27     ~27, !1
         39        ROPE_ADD                                      2  ~27     ~27, '%2F'
         40        ROPE_END                                      3  ~26     ~27, !0
         41        ASSIGN                                                   !4, ~26
         42      > JMP                                                      ->47
  226    43    >   NEW                                              $30     'BestBuy%5CException%5CInvalidArgumentException'
         44        SEND_VAL_EX                                              '%60%24type%60+must+be+one+of+%60Client%3A%3ARECOMMENDATIONS_%2A%60'
         45        DO_FCALL                                      0          
         46      > THROW                                         0          $30
  229    47    >   INIT_METHOD_CALL                                         'doRequest'
  230    48        FETCH_CLASS_CONSTANT                             ~32     'URL_BETA'
         49        SEND_VAL_EX                                              ~32
         50        SEND_VAR_EX                                              !4
         51        SEND_VAR_EX                                              !2
         52        DO_FCALL                                      0  $33     
         53      > RETURN                                                   $33
  234    54*     > RETURN                                                   null

End of function recommendations

Function reviews:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bT8JG
function name:  reviews
number of ops:  9
compiled vars:  !0 = $search, !1 = $responseConfig
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  243     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      <array>
  245     2        INIT_METHOD_CALL                                         'simpleEndpoint'
          3        SEND_VAL_EX                                              'reviews'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
  246     8*     > RETURN                                                   null

End of function reviews

Function setlogger:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bT8JG
function name:  setLogger
number of ops:  4
compiled vars:  !0 = $logger
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  256     0  E >   RECV                                             !0      
  258     1        ASSIGN_OBJ                                               'logger'
          2        OP_DATA                                                  !0
  259     3      > RETURN                                                   null

End of function setlogger

Function stores:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bT8JG
function name:  stores
number of ops:  9
compiled vars:  !0 = $search, !1 = $responseConfig
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  268     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      <array>
  270     2        INIT_METHOD_CALL                                         'simpleEndpoint'
          3        SEND_VAL_EX                                              'stores'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
  271     8*     > RETURN                                                   null

End of function stores

Function buildurl:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/bT8JG
function name:  buildUrl
number of ops:  38
compiled vars:  !0 = $root, !1 = $path, !2 = $responseConfig, !3 = $querystring
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  282     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
  285     3        FETCH_OBJ_R                                      ~4      'config'
          4        FETCH_DIM_R                                      ~5      ~4, 'key'
          5        BOOL_NOT                                         ~6      ~5
          6      > JMPZ                                                     ~6, ->11
  286     7    >   NEW                                              $7      'BestBuy%5CException%5CAuthorizationException'
  289     8        SEND_VAL_EX                                              'A+Best+Buy+developer+API+key+is+required.+Register+for+one+at+developer.bestbuy.com%2C+call+new+%60%5CBestBuy%5CClient%28YOUR_API_KEY%29%60%2C+or+specify+a+BBY_API_KEY+system+environment+variable.'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $7
  293    11    >   FETCH_OBJ_R                                      ~10     'config'
         12        FETCH_DIM_R                                      ~11     ~10, 'key'
         13        ASSIGN_DIM                                               !2, 'apiKey'
         14        OP_DATA                                                  ~11
  296    15        INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cpreg_match'
         16        SEND_VAL_EX                                              '%2F%5C.json%24%2F'
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $12     
         19        BOOL_NOT                                         ~13     $12
         20      > JMPZ                                                     ~13, ->23
  297    21    >   ASSIGN_DIM                                               !2, 'format'
         22        OP_DATA                                                  'json'
  299    23    >   INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Chttp_build_query'
         24        SEND_VAR_EX                                              !2
         25        DO_FCALL                                      0  $15     
         26        ASSIGN                                                   !3, $15
  302    27        INIT_NS_FCALL_BY_NAME                                    'BestBuy%5Cpreg_replace'
         28        SEND_VAL_EX                                              '%2F%5Cs%2B%2F'
         29        SEND_VAL_EX                                              '%2520'
         30        ROPE_INIT                                     4  ~18     !0
         31        ROPE_ADD                                      1  ~18     ~18, !1
         32        ROPE_ADD                                      2  ~18     ~18, '%3F'
         33        ROPE_END                                      3  ~17     ~18, !3
         34        SEND_VAL_EX                                              ~17
         35        DO_FCALL                                      0  $20     
         36      > RETURN                                                   $20
  303    37*     > RETURN                               

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
297.03 ms | 1428 KiB | 32 Q