@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @throws InvalidArgumentException |
| 27 | 27 | */ |
| 28 | - public function first_performance_date(string $timezone = 'America/New_York'): DateTime|bool |
|
| 28 | + public function first_performance_date(string $timezone = 'America/New_York'): DateTime | bool |
|
| 29 | 29 | { |
| 30 | 30 | try { |
| 31 | 31 | $timezone = new DateTimeZone($timezone); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @throws InvalidArgumentException |
| 49 | 49 | */ |
| 50 | - public function last_performance_date(string $timezone = 'America/New_York'): DateTime|bool |
|
| 50 | + public function last_performance_date(string $timezone = 'America/New_York'): DateTime | bool |
|
| 51 | 51 | { |
| 52 | 52 | try { |
| 53 | 53 | $timezone = new DateTimeZone($timezone); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | $response = $this->client->get(self::RESOURCE); |
| 51 | 51 | $data = json_decode($response->getBody()->getContents(), true); |
| 52 | 52 | |
| 53 | - return array_map( function(array $season) { |
|
| 53 | + return array_map(function(array $season) { |
|
| 54 | 54 | return new Season($season); |
| 55 | 55 | }, $data); |
| 56 | 56 | } catch (GuzzleException $e) { |
@@ -18,26 +18,26 @@ discard block |
||
| 18 | 18 | * @param string[] $args Optional array of arguments to set the object's state. |
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | - public function __construct( array $args = [] ) |
|
| 21 | + public function __construct(array $args = []) |
|
| 22 | 22 | { |
| 23 | - $this->_set_state( $args ); |
|
| 23 | + $this->_set_state($args); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @param string[] $args |
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | - protected function _set_state( array $args = [] ) : void |
|
| 30 | + protected function _set_state(array $args = []) : void |
|
| 31 | 31 | { |
| 32 | - foreach ( $args as $key => $value ) { |
|
| 32 | + foreach ($args as $key => $value) { |
|
| 33 | 33 | $property = "_{$key}"; |
| 34 | 34 | |
| 35 | - switch ( property_exists ( $this, $property ) ) { |
|
| 35 | + switch (property_exists($this, $property)) { |
|
| 36 | 36 | case true : |
| 37 | 37 | $this->{$property} = $value; |
| 38 | 38 | break; |
| 39 | 39 | default : |
| 40 | - $this->_extra_args[ $key ] = $value; |
|
| 40 | + $this->_extra_args[$key] = $value; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -49,16 +49,16 @@ discard block |
||
| 49 | 49 | * @param mixed[] $args Optional array of arguments passed to the method call. |
| 50 | 50 | * @return mixed The value of the corresponding property or extra argument if available, or false if neither exists. |
| 51 | 51 | */ |
| 52 | - public function __call( string $name, array $args = [] ): mixed |
|
| 52 | + public function __call(string $name, array $args = []): mixed |
|
| 53 | 53 | { |
| 54 | 54 | $property = "_{$name}"; |
| 55 | 55 | |
| 56 | - if ( property_exists ( $this, $property ) ) { |
|
| 56 | + if (property_exists($this, $property)) { |
|
| 57 | 57 | return $this->{$property}; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ( isset ( $this->_extra_args[ $name ] ) ) { |
|
| 61 | - return $this->_extra_args[ $name ]; |
|
| 60 | + if (isset ($this->_extra_args[$name])) { |
|
| 61 | + return $this->_extra_args[$name]; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | return false; |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | * @param mixed[] $defaults Array of default key-value pairs. |
| 72 | 72 | * @return mixed[] The merged array where defaults are overridden by provided arguments. |
| 73 | 73 | */ |
| 74 | - public function parse_args( array $args = [], array $defaults = [] ) : array |
|
| 74 | + public function parse_args(array $args = [], array $defaults = []) : array |
|
| 75 | 75 | { |
| 76 | - foreach ( $defaults as $key => $value ) { |
|
| 77 | - if ( isset ( $args[ $key ] ) ) { |
|
| 76 | + foreach ($defaults as $key => $value) { |
|
| 77 | + if (isset ($args[$key])) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $args[ $key ] = $value; |
|
| 81 | + $args[$key] = $value; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | return $args; |
@@ -15,13 +15,13 @@ |
||
| 15 | 15 | |
| 16 | 16 | public function zoneId() : int { |
| 17 | 17 | |
| 18 | - return intval( $this->_extra_args['ZoneId'] ); |
|
| 18 | + return intval($this->_extra_args['ZoneId']); |
|
| 19 | 19 | |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function enabled(): bool |
| 23 | 23 | { |
| 24 | - return (bool)$this->_extra_args['Enabled']; |
|
| 24 | + return (bool) $this->_extra_args['Enabled']; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function performanceId(): int |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | public function description(): string |
| 32 | 32 | { |
| 33 | 33 | |
| 34 | - return (string)$this->_extra_args['PerformanceDescription']; |
|
| 34 | + return (string) $this->_extra_args['PerformanceDescription']; |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param mixed[] $args |
| 210 | 210 | * @return Exception|mixed[] |
| 211 | 211 | */ |
| 212 | - public function post(string $endpoint, array $args = []): array|Exception |
|
| 212 | + public function post(string $endpoint, array $args = []): array | Exception |
|
| 213 | 213 | { |
| 214 | 214 | |
| 215 | 215 | $args = array_merge($args, array( |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | 'log' => 'tessitura', |
| 238 | 238 | )); |
| 239 | 239 | |
| 240 | - $message = 'Tessitura API: ' . $message; |
|
| 240 | + $message = 'Tessitura API: '.$message; |
|
| 241 | 241 | |
| 242 | 242 | if ($this->logger()) { |
| 243 | 243 | $this->logger()->log($message, $args); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | const RESOURCE = 'TXN/Performances'; |
| 14 | 14 | protected Api $_api; |
| 15 | 15 | |
| 16 | - public function __construct(Api|null $api = null) |
|
| 16 | + public function __construct(Api | null $api = null) |
|
| 17 | 17 | { |
| 18 | 18 | if (empty ($api)) { |
| 19 | 19 | $api = new Api(); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $results = $this->_api->post($endpoint, $args); |
| 92 | 92 | |
| 93 | - return array_map(function ($item) { |
|
| 93 | + return array_map(function($item) { |
|
| 94 | 94 | return new Performance($item); |
| 95 | 95 | }, $results); |
| 96 | 96 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | public function get_performances_for_production_season(int $psId): array |
| 102 | 102 | { |
| 103 | 103 | return $this->search([ |
| 104 | - 'ProductionSeasonIds' => (string)$psId, |
|
| 104 | + 'ProductionSeasonIds' => (string) $psId, |
|
| 105 | 105 | ]); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -113,24 +113,24 @@ discard block |
||
| 113 | 113 | $prices = $this->getPricesForPerformance($performanceId); |
| 114 | 114 | |
| 115 | 115 | // Filter out zones that do not have any available seats |
| 116 | - foreach($zones as $zone) { |
|
| 117 | - if ( $zone->availableCount() > 0 ) { |
|
| 116 | + foreach ($zones as $zone) { |
|
| 117 | + if ($zone->availableCount() > 0) { |
|
| 118 | 118 | $available_zones[] = $zone->zone()->id; |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - foreach( $prices as $price ) { |
|
| 122 | + foreach ($prices as $price) { |
|
| 123 | 123 | // is this price for a zone that has available seats? |
| 124 | - if ( in_array( $price->zoneId(), $available_zones ) ) { |
|
| 124 | + if (in_array($price->zoneId(), $available_zones)) { |
|
| 125 | 125 | // It is. Is this price 0? Then skip. Is this price more than the current best price? Then skip. |
| 126 | - if ( $price->price() && ( $price->price() < $best_price || 0 === $best_price ) ) { |
|
| 126 | + if ($price->price() && ($price->price() < $best_price || 0 === $best_price)) { |
|
| 127 | 127 | // The current price is non-zero. Update the best price to this value |
| 128 | 128 | $best_price = $price->price(); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - return intval( $best_price ); |
|
| 133 | + return intval($best_price); |
|
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @link https://docs.tessitura.com/REST_v151/TessituraService/HELP/API/GET_TXN_PERFORMANCES_ZONES_PERF.HTM |
| 143 | 143 | */ |
| 144 | - public function getPerformanceZoneAvailabilities(int $performanceId ): array { |
|
| 144 | + public function getPerformanceZoneAvailabilities(int $performanceId): array { |
|
| 145 | 145 | |
| 146 | - try{ |
|
| 147 | - $data = $this->_api->get( sprintf( '%1$s/Zones?performanceIds=%2$s', self::RESOURCE, $performanceId ) ); |
|
| 146 | + try { |
|
| 147 | + $data = $this->_api->get(sprintf('%1$s/Zones?performanceIds=%2$s', self::RESOURCE, $performanceId)); |
|
| 148 | 148 | |
| 149 | - if ( is_array( $data ) ) { |
|
| 150 | - return array_map( [$this, 'makeNewZoneAvailability'], $data ); |
|
| 149 | + if (is_array($data)) { |
|
| 150 | + return array_map([$this, 'makeNewZoneAvailability'], $data); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return []; |
@@ -163,19 +163,19 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function makeNewZoneAvailability(array $data) : PZA { |
| 165 | 165 | |
| 166 | - $data = $this->parse_args( $data, [ |
|
| 166 | + $data = $this->parse_args($data, [ |
|
| 167 | 167 | 'AvailableCount' => 0, |
| 168 | 168 | 'Id' => 0, |
| 169 | 169 | 'Inactive' => false, |
| 170 | 170 | 'PerformanceId' => 0, |
| 171 | 171 | 'SectionSummaries' => null, |
| 172 | 172 | 'Zone' => null, |
| 173 | - ] ); |
|
| 173 | + ]); |
|
| 174 | 174 | |
| 175 | - return new PZA( [ |
|
| 175 | + return new PZA([ |
|
| 176 | 176 | 'availableCount' => $data['AvailableCount'], |
| 177 | 177 | 'zone' => $data['Zone'], |
| 178 | - ] ); |
|
| 178 | + ]); |
|
| 179 | 179 | |
| 180 | 180 | } |
| 181 | 181 | |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | 199 | try { |
| 200 | - $results = $this->_api->get( self::RESOURCE . '/Prices', $args ); |
|
| 200 | + $results = $this->_api->get(self::RESOURCE.'/Prices', $args); |
|
| 201 | 201 | |
| 202 | 202 | if (is_array($results)) { |
| 203 | - foreach ( $results as $item ) { |
|
| 203 | + foreach ($results as $item) { |
|
| 204 | 204 | $prices[] = new PriceSummary($item); |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - unset( $results ); |
|
| 211 | + unset($results); |
|
| 212 | 212 | |
| 213 | 213 | return $prices; |
| 214 | 214 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $timezone = new DateTimeZone(date_default_timezone_get()); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if(isset($this->extra_args()['CreatedDateTime'])) { |
|
| 19 | + if (isset($this->extra_args()['CreatedDateTime'])) { |
|
| 20 | 20 | try { |
| 21 | 21 | return new DateTime($this->extra_args()['CreatedDateTime'], $timezone); |
| 22 | 22 | } catch (\Exception $e) { |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function description(): string |
| 31 | 31 | { |
| 32 | - return (string)$this->extra_args()['Description']; |
|
| 32 | + return (string) $this->extra_args()['Description']; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function endDateTime(string $timezone = 'America/New_York') : ?DateTime |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | $timezone = new DateTimeZone(date_default_timezone_get()); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(isset( $this->extra_args()['EndDateTime'])) { |
|
| 45 | + if (isset($this->extra_args()['EndDateTime'])) { |
|
| 46 | 46 | try { |
| 47 | - return new \DateTime( $this->extra_args()['EndDateTime'], $timezone ); |
|
| 47 | + return new \DateTime($this->extra_args()['EndDateTime'], $timezone); |
|
| 48 | 48 | } catch (\Exception $exception) { |
| 49 | 49 | trigger_error($exception->getMessage(), E_USER_WARNING); |
| 50 | 50 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | if (isset($this->extra_args()['StartDateTime'])) { |
| 72 | 72 | try { |
| 73 | - return new \DateTime( $this->extra_args()['StartDateTime'], $timezone ); |
|
| 73 | + return new \DateTime($this->extra_args()['StartDateTime'], $timezone); |
|
| 74 | 74 | } catch (\Exception $e) { |
| 75 | 75 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 76 | 76 | } |