コード例 #1
0
 public function test_toFromAssociativeArray_shouldBeCorrect()
 {
     $platformTargeting = new PlatformTargeting(false, false);
     $array = $platformTargeting->toAssociativeArray();
     $this->assertEquals(array(PlatformTargeting::DESKTOP => false, PlatformTargeting::MOBILE => false, PlatformTargeting::VERSION => PlatformTargeting::CURR_VERSION), $array);
     $newPlatformTargeting = PlatformTargeting::fromAssociativeArray($array);
     $this->assertFalse($newPlatformTargeting->getMobile());
     $this->assertFalse($newPlatformTargeting->getDesktop());
 }
コード例 #2
0
 public static function fromAssociativeArray($firehoundBlobArray)
 {
     $name = isset($firehoundBlobArray[self::NAME]) ? $firehoundBlobArray[self::NAME] : null;
     $identifier = isset($firehoundBlobArray[self::IDENTIFIER]) ? $firehoundBlobArray[self::IDENTIFIER] : null;
     $startDate = isset($firehoundBlobArray[self::START_DATE]) ? $firehoundBlobArray[self::START_DATE] : null;
     $endDate = isset($firehoundBlobArray[self::END_DATE]) ? $firehoundBlobArray[self::END_DATE] : null;
     $budgets = null;
     if (isset($firehoundBlobArray[self::BUDGETS]) && is_array($firehoundBlobArray[self::BUDGETS])) {
         $budgets = array();
         foreach ($firehoundBlobArray[self::BUDGETS] as $key => $budgetArray) {
             $budgets[$key] = Budget::fromAssociativeArray($budgetArray);
         }
     }
     $budget = is_array($budgets) ? $budgets : null;
     $targeting = isset($firehoundBlobArray[self::TARGETING]) ? Targeting::fromAssociativeArray($firehoundBlobArray[self::TARGETING]) : null;
     $platformTargeting = isset($firehoundBlobArray[self::PLATFORM_TARGETING]) ? PlatformTargeting::fromAssociativeArray($firehoundBlobArray[self::PLATFORM_TARGETING]) : null;
     $exchangeTargeting = isset($firehoundBlobArray[self::EXCHANGE_TARGETING]) ? ExchangeTargeting::fromAssociativeArray($firehoundBlobArray[self::EXCHANGE_TARGETING]) : null;
     $creative = self::getCreativeFromBlobArray($firehoundBlobArray);
     $context = isset($firehoundBlobArray[self::CONTEXT]) ? Context::fromAssociativeArray($firehoundBlobArray[self::CONTEXT]) : null;
     $firehoundBlob = new FirehoundBlob($name, $identifier, $startDate, $endDate, $budget, $targeting, $platformTargeting, $exchangeTargeting, $creative, $context);
     return $firehoundBlob;
 }