コード例 #1
0
ファイル: model.php プロジェクト: mehulsbhatt/volcano
 /**
  * Returns whether the model's status is active.
  *
  * @return bool
  */
 public function active()
 {
     if (!Arr::key_exists($this::properties(), 'status')) {
         return false;
     }
     return $this->status == 'active';
 }
コード例 #2
0
ファイル: arr.php プロジェクト: quickpacket/noclayer
 /**
  * Tests Arr::key_exists()
  *
  * @test
  * @dataProvider person_provider
  */
 public function test_key_exists_with_dot_separated_key($person)
 {
     $expected = true;
     $output = Arr::key_exists($person, "location.city");
     $this->assertEquals($expected, $output);
 }
コード例 #3
0
ファイル: contacts.php プロジェクト: mehulsbhatt/volcano
 /**
  * Attempts to get a contact from a given ID.
  *
  * @param int $id Contact ID.
  *
  * @return \Model_Contact
  */
 protected function get_contact($id)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $contact = \Service_Contact::find_one($id);
     if (!$contact || !\Arr::key_exists(\Seller::active()->contacts, $contact->id)) {
         throw new HttpNotFoundException();
     }
     return $contact;
 }
コード例 #4
0
ファイル: curl.php プロジェクト: SainsburysTests/sainsburys
 /**
  * Function to encode input array depending on the content type
  *
  * @param   array $input
  * @return  mixed encoded output
  */
 protected function encode(array $input)
 {
     // Detect the request content type, default to 'text/plain'
     $content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : $this->response_info('content_type', 'text/plain');
     // Get the correct format for the current content type
     $format = \Arr::key_exists(static::$auto_detect_formats, $content_type) ? static::$auto_detect_formats[$content_type] : null;
     switch ($format) {
         // Format as XML
         case 'xml':
             /**
              * If the input array has one item in the top level
              * then use that item as the root XML element.
              */
             if (count($input) === 1) {
                 $base_node = key($input);
                 return \Format::forge($input[$base_node])->to_xml(null, null, $base_node);
             } else {
                 return \Format::forge($input)->to_xml();
             }
             break;
             // Format as JSON
         // Format as JSON
         case 'json':
             return \Format::forge($input)->to_json();
             break;
             // Format as PHP Serialized Array
         // Format as PHP Serialized Array
         case 'serialize':
             return \Format::forge($input)->to_serialize();
             break;
             // Format as PHP Array
         // Format as PHP Array
         case 'php':
             return \Format::forge($input)->to_php();
             break;
             // Format as CSV
         // Format as CSV
         case 'csv':
             return \Format::forge($input)->to_csv();
             break;
         default:
             if (count($input) === 1 and key($input) === 'form-data') {
                 // multipart/form-data
                 return $input['form-data'];
             } else {
                 //application/x-www-form-urlencoded
                 return http_build_query($input, null, '&');
             }
             break;
     }
 }
コード例 #5
0
ファイル: contacts.php プロジェクト: mehulsbhatt/volcano
 /**
  * Attempts to get a contact from a given ID.
  *
  * @param int             $id       Contact ID.
  * @param \Model_Customer $customer Customer the contact should belong to.
  *
  * @return \Model_Contact
  */
 protected function get_contact($id, \Model_Customer $customer)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $contact = \Service_Contact::find_one($id);
     if (!$contact || !\Arr::key_exists($customer->contacts, $contact->id)) {
         throw new HttpNotFoundException();
     }
     return $contact;
 }