comparison vendor/zendframework/zend-feed/src/PubSubHubbub/Model/Subscription.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
29 * @return bool 29 * @return bool
30 * @throws PubSubHubbub\Exception\InvalidArgumentException 30 * @throws PubSubHubbub\Exception\InvalidArgumentException
31 */ 31 */
32 public function setSubscription(array $data) 32 public function setSubscription(array $data)
33 { 33 {
34 if (!isset($data['id'])) { 34 if (! isset($data['id'])) {
35 throw new PubSubHubbub\Exception\InvalidArgumentException( 35 throw new PubSubHubbub\Exception\InvalidArgumentException(
36 'ID must be set before attempting a save' 36 'ID must be set before attempting a save'
37 ); 37 );
38 } 38 }
39 $result = $this->db->select(['id' => $data['id']]); 39 $result = $this->db->select(['id' => $data['id']]);
64 * @return array 64 * @return array
65 * @throws PubSubHubbub\Exception\InvalidArgumentException 65 * @throws PubSubHubbub\Exception\InvalidArgumentException
66 */ 66 */
67 public function getSubscription($key) 67 public function getSubscription($key)
68 { 68 {
69 if (empty($key) || !is_string($key)) { 69 if (empty($key) || ! is_string($key)) {
70 throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"' 70 throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"'
71 .' of "' . $key . '" must be a non-empty string'); 71 .' of "' . $key . '" must be a non-empty string');
72 } 72 }
73 $result = $this->db->select(['id' => $key]); 73 $result = $this->db->select(['id' => $key]);
74 if (count($result)) { 74 if ($result && count($result)) {
75 return $result->current()->getArrayCopy(); 75 return $result->current()->getArrayCopy();
76 } 76 }
77 return false; 77 return false;
78 } 78 }
79 79
84 * @return bool 84 * @return bool
85 * @throws PubSubHubbub\Exception\InvalidArgumentException 85 * @throws PubSubHubbub\Exception\InvalidArgumentException
86 */ 86 */
87 public function hasSubscription($key) 87 public function hasSubscription($key)
88 { 88 {
89 if (empty($key) || !is_string($key)) { 89 if (empty($key) || ! is_string($key)) {
90 throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"' 90 throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"'
91 .' of "' . $key . '" must be a non-empty string'); 91 .' of "' . $key . '" must be a non-empty string');
92 } 92 }
93 $result = $this->db->select(['id' => $key]); 93 $result = $this->db->select(['id' => $key]);
94 if (count($result)) { 94 if ($result && count($result)) {
95 return true; 95 return true;
96 } 96 }
97 return false; 97 return false;
98 } 98 }
99 99
104 * @return bool 104 * @return bool
105 */ 105 */
106 public function deleteSubscription($key) 106 public function deleteSubscription($key)
107 { 107 {
108 $result = $this->db->select(['id' => $key]); 108 $result = $this->db->select(['id' => $key]);
109 if (count($result)) { 109 if ($result && count($result)) {
110 $this->db->delete( 110 $this->db->delete(
111 ['id' => $key] 111 ['id' => $key]
112 ); 112 );
113 return true; 113 return true;
114 } 114 }