@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | private $faultyUser = null; |
| 42 | 42 | |
| 43 | - protected function setUp(){ |
|
| 43 | + protected function setUp() { |
|
| 44 | 44 | $this->profile = new MockProfileSilverbullet(\core\DBConnection::handle('INST')); |
| 45 | 45 | $this->profileId = $this->profile->identifier; |
| 46 | 46 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $list = SilverbulletCertificate::getList($this->newUser); |
| 71 | 71 | $found = false; |
| 72 | 72 | foreach ($list as $certificate) { |
| 73 | - if($certificate->getIdentifier() == $this->newCertificate->getIdentifier()){ |
|
| 73 | + if ($certificate->getIdentifier() == $this->newCertificate->getIdentifier()) { |
|
| 74 | 74 | $found = true; |
| 75 | 75 | break; |
| 76 | 76 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $this->assertTrue($result); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function testNewCertificateFailure(){ |
|
| 92 | + public function testNewCertificateFailure() { |
|
| 93 | 93 | $this->faultyCertificate->save(); |
| 94 | 94 | $this->assertEmpty($this->faultyCertificate->getIdentifier()); |
| 95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $list = SilverbulletCertificate::getList($this->faultyUser); |
| 100 | 100 | $found = false; |
| 101 | 101 | foreach ($list as $certificate) { |
| 102 | - if($certificate->getIdentifier() == $this->faultyCertificate->getIdentifier()){ |
|
| 102 | + if ($certificate->getIdentifier() == $this->faultyCertificate->getIdentifier()) { |
|
| 103 | 103 | $found = true; |
| 104 | 104 | break; |
| 105 | 105 | } |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | $this->assertFalse($found); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function testFaultyCertificateLoadFailure(){ |
|
| 110 | + public function testFaultyCertificateLoadFailure() { |
|
| 111 | 111 | $this->faultyCertificate->load(); |
| 112 | 112 | $this->assertEmpty($this->faultyCertificate->getIdentifier()); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function testSetRevoked(){ |
|
| 115 | + public function testSetRevoked() { |
|
| 116 | 116 | $this->newCertificate->save(); |
| 117 | 117 | $this->assertNotEmpty($this->newCertificate->getIdentifier()); |
| 118 | 118 | |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | $this->assertEquals(SilverbulletCertificate::NOT_REVOKED, $existingCertificate->get(SilverbulletCertificate::REVOCATION_STATUS)); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - protected function tearDown(){ |
|
| 139 | + protected function tearDown() { |
|
| 140 | 140 | $this->newUser->delete(); |
| 141 | - if(!empty($this->faultyCertificate)){ |
|
| 141 | + if (!empty($this->faultyCertificate)) { |
|
| 142 | 142 | $this->faultyCertificate->delete(); |
| 143 | 143 | } |
| 144 | 144 | $this->profile->delete(); |
@@ -2,19 +2,19 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | use web\lib\admin\utils\CSVParser; |
| 4 | 4 | |
| 5 | -class MockCSVParser extends CSVParser{ |
|
| 5 | +class MockCSVParser extends CSVParser { |
|
| 6 | 6 | |
| 7 | 7 | public function __construct($fileData, $rowDelimiter, $tokenDelimiter) { |
| 8 | 8 | $this->rowDelimiter = $rowDelimiter; |
| 9 | 9 | $this->tokenDelimiter = $tokenDelimiter; |
| 10 | - if($this->validate($fileData)){ |
|
| 10 | + if ($this->validate($fileData)) { |
|
| 11 | 11 | $this->rows = str_getcsv($fileData['contents'], $this->rowDelimiter); |
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -class CSVParserTest extends PHPUnit_Framework_TestCase{ |
|
| 17 | +class CSVParserTest extends PHPUnit_Framework_TestCase { |
|
| 18 | 18 | |
| 19 | 19 | private $rowDelimiter = "\n", $tokenDelimiter = ","; |
| 20 | 20 | |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | 'contents' => "" |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - protected function setUp(){ |
|
| 56 | - $this->successFileData['contents'] = "testuser1,".date('Y-m-d',strtotime("+1 month")).",2 |
|
| 57 | - testuser2,".date('Y-m-d',strtotime("+2 month")).", |
|
| 58 | - testuser3,".date('Y-m-d',strtotime("+1 month")).",1 |
|
| 59 | - testuser4,".date('Y-m-d',strtotime("+3 month")).", |
|
| 60 | - testuser5,".date('Y-m-d',strtotime("+1 month")).",3"; |
|
| 55 | + protected function setUp() { |
|
| 56 | + $this->successFileData['contents'] = "testuser1," . date('Y-m-d', strtotime("+1 month")) . ",2 |
|
| 57 | + testuser2,".date('Y-m-d', strtotime("+2 month")) . ", |
|
| 58 | + testuser3,".date('Y-m-d', strtotime("+1 month")) . ",1 |
|
| 59 | + testuser4,".date('Y-m-d', strtotime("+3 month")) . ", |
|
| 60 | + testuser5,".date('Y-m-d', strtotime("+1 month")) . ",3"; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function testIsValid(){ |
|
| 63 | + public function testIsValid() { |
|
| 64 | 64 | $parser = new MockCSVParser($this->faultyFileData, $this->rowDelimiter, $this->tokenDelimiter); |
| 65 | 65 | $this->assertFalse($parser->isValid()); |
| 66 | 66 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $this->assertTrue($parser->isValid()); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function testHasMoreRows(){ |
|
| 79 | + public function testHasMoreRows() { |
|
| 80 | 80 | $parser = new MockCSVParser($this->faultyFileData, $this->rowDelimiter, $this->tokenDelimiter); |
| 81 | 81 | $this->assertFalse($parser->hasMoreRows()); |
| 82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $this->assertTrue($parser->hasMoreRows()); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function testNextRow(){ |
|
| 90 | + public function testNextRow() { |
|
| 91 | 91 | $parser = new MockCSVParser($this->faultyFileData, $this->rowDelimiter, $this->tokenDelimiter); |
| 92 | 92 | $this->assertCount(0, $parser->nextRow()); |
| 93 | 93 | |
@@ -1,14 +1,14 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | use web\lib\admin\storage\SessionStorage; |
| 3 | 3 | |
| 4 | -if ( !isset( $_SESSION ) ) $_SESSION = array(); |
|
| 4 | +if (!isset($_SESSION)) $_SESSION = array(); |
|
| 5 | 5 | |
| 6 | -class SessionStorageTest extends PHPUnit_Framework_TestCase{ |
|
| 7 | - protected $backupGlobalsBlacklist = array( '_SESSION' ); |
|
| 6 | +class SessionStorageTest extends PHPUnit_Framework_TestCase { |
|
| 7 | + protected $backupGlobalsBlacklist = array('_SESSION'); |
|
| 8 | 8 | private $package1 = "testpackage1"; |
| 9 | 9 | private $package2 = "testpackage2"; |
| 10 | 10 | |
| 11 | - public function testGetInstance(){ |
|
| 11 | + public function testGetInstance() { |
|
| 12 | 12 | $globalSession = SessionStorage::getInstance(); |
| 13 | 13 | $scopedSession1 = SessionStorage::getInstance($this->package1); |
| 14 | 14 | $scopedSession2 = SessionStorage::getInstance($this->package2); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $this->assertNotEquals($scopedSession1, $scopedSession2); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function testPut(){ |
|
| 24 | + public function testPut() { |
|
| 25 | 25 | $testPutGlobal = "testputglobal"; |
| 26 | 26 | $globalSession = SessionStorage::getInstance(); |
| 27 | 27 | $globalSession->put($testPutGlobal, $testPutGlobal); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $this->assertNotEquals($_SESSION[SessionStorage::INDEX][SessionStorage::SCOPED][$this->package1][$testPutScoped1], $_SESSION[SessionStorage::INDEX][SessionStorage::SCOPED][$this->package2][$testPutScoped2]); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function testGet(){ |
|
| 44 | + public function testGet() { |
|
| 45 | 45 | $testGetGlobal = "testgetglobal"; |
| 46 | 46 | $globalSession = SessionStorage::getInstance(); |
| 47 | 47 | $_SESSION[SessionStorage::INDEX][SessionStorage::WIDE][$testGetGlobal] = $testGetGlobal; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $this->assertNotEquals($scopedSession2->get($testGetScoped2), $scopedSession1->get($testGetScoped1)); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function testDelete(){ |
|
| 65 | + public function testDelete() { |
|
| 66 | 66 | $testGetGlobal = "testgetglobal"; |
| 67 | 67 | $globalSession = SessionStorage::getInstance(); |
| 68 | 68 | $_SESSION[SessionStorage::INDEX][SessionStorage::WIDE][$testGetGlobal] = $testGetGlobal; |
@@ -1,7 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use web\lib\admin\storage\SessionStorage; |
| 3 | 3 | |
| 4 | -if ( !isset( $_SESSION ) ) $_SESSION = array(); |
|
| 4 | +if ( !isset( $_SESSION ) ) { |
|
| 5 | + $_SESSION = array(); |
|
| 6 | +} |
|
| 5 | 7 | |
| 6 | 8 | class SessionStorageTest extends PHPUnit_Framework_TestCase{ |
| 7 | 9 | protected $backupGlobalsBlacklist = array( '_SESSION' ); |
@@ -1,19 +1,19 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | use web\lib\admin\view\html\Attribute; |
| 3 | 3 | |
| 4 | -class AttributeTest extends \PHPUnit_Framework_TestCase{ |
|
| 4 | +class AttributeTest extends \PHPUnit_Framework_TestCase { |
|
| 5 | 5 | |
| 6 | - private function validateString($attribute){ |
|
| 6 | + private function validateString($attribute) { |
|
| 7 | 7 | $string = $attribute->__toString(); |
| 8 | 8 | $this->assertNotEmpty($string); |
| 9 | 9 | |
| 10 | 10 | $space = substr($string, 0, 1); |
| 11 | - $this->assertEquals($space,' '); |
|
| 11 | + $this->assertEquals($space, ' '); |
|
| 12 | 12 | |
| 13 | 13 | $spaceRemoved = substr($string, 1); |
| 14 | 14 | $pair = explode('=', $spaceRemoved, 2); |
| 15 | 15 | |
| 16 | - if(count($pair)>1){ |
|
| 16 | + if (count($pair) > 1) { |
|
| 17 | 17 | $this->assertTrue(strlen($pair[0]) > 0); |
| 18 | 18 | $this->assertTrue(strlen($pair[1]) > 2); |
| 19 | 19 | $this->assertEquals(substr_count($pair[0], '"'), 0); |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | $this->assertEmpty($string); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function testValidToString(){ |
|
| 35 | + public function testValidToString() { |
|
| 36 | 36 | $this->validateString(new Attribute("type", "button")); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function testFaultyToString(){ |
|
| 39 | + public function testFaultyToString() { |
|
| 40 | 40 | $this->validateString(new Attribute("t\"ype", "b=ut\"ton")); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -2,13 +2,13 @@ discard block |
||
| 2 | 2 | use web\lib\admin\view\html\CompositeTag; |
| 3 | 3 | use web\lib\admin\view\html\Tag; |
| 4 | 4 | |
| 5 | -class CompositeTagTest extends \PHPUnit_Framework_TestCase{ |
|
| 5 | +class CompositeTagTest extends \PHPUnit_Framework_TestCase { |
|
| 6 | 6 | |
| 7 | 7 | private $compositeTag; |
| 8 | 8 | |
| 9 | 9 | private $tag; |
| 10 | 10 | |
| 11 | - protected function setUp(){ |
|
| 11 | + protected function setUp() { |
|
| 12 | 12 | $this->compositeTag = new CompositeTag('div'); |
| 13 | 13 | $this->tag = new Tag('p'); |
| 14 | 14 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $this->assertTrue(in_array($this->tag, $tags)); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function testToString(){ |
|
| 26 | + public function testToString() { |
|
| 27 | 27 | $string = $this->compositeTag->__toString(); |
| 28 | 28 | $this->assertEquals('<div>', substr(trim($string), 0, 5)); |
| 29 | 29 | $this->assertEquals('</div>', substr(trim($string), -6)); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $this->assertEquals('<div>', substr(trim($string), 0, 5)); |
| 34 | 34 | $this->assertEquals('</div>', substr(trim($string), -6)); |
| 35 | 35 | |
| 36 | - $string = str_replace(array('<div>','</div>'), '', $string); |
|
| 36 | + $string = str_replace(array('<div>', '</div>'), '', $string); |
|
| 37 | 37 | $this->assertEquals('<p>', substr(trim($string), 0, 3)); |
| 38 | 38 | $this->assertEquals('</p>', substr(trim($string), -4)); |
| 39 | 39 | } |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | use web\lib\admin\view\html\Button; |
| 3 | 3 | |
| 4 | -class ButtonTest extends \PHPUnit_Framework_TestCase{ |
|
| 4 | +class ButtonTest extends \PHPUnit_Framework_TestCase { |
|
| 5 | 5 | |
| 6 | 6 | private $title; |
| 7 | 7 | |
| 8 | - protected function setUp(){ |
|
| 8 | + protected function setUp() { |
|
| 9 | 9 | $this->title = 'Some title'; |
| 10 | 10 | } |
| 11 | 11 | |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | $button = new Button($this->title, $type, $name, $value, $class); |
| 27 | 27 | $string = $button->__toString(); |
| 28 | 28 | |
| 29 | - $this->assertNotEquals(strpos($string, 'type="'.$type.'"'), false); |
|
| 30 | - $this->assertNotEquals(strpos($string, 'name="'.$name.'"'), false); |
|
| 31 | - $this->assertNotEquals(strpos($string, 'value="'.$value.'"'), false); |
|
| 32 | - $this->assertNotEquals(strpos($string, 'class="'.$class.'"'), false); |
|
| 29 | + $this->assertNotEquals(strpos($string, 'type="' . $type . '"'), false); |
|
| 30 | + $this->assertNotEquals(strpos($string, 'name="' . $name . '"'), false); |
|
| 31 | + $this->assertNotEquals(strpos($string, 'value="' . $value . '"'), false); |
|
| 32 | + $this->assertNotEquals(strpos($string, 'class="' . $class . '"'), false); |
|
| 33 | 33 | $this->assertNotEquals(strpos($string, $this->title), false); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | if(!empty($user->getIdentifier())){ |
| 14 | 14 | $this->storeInfoMessage(_('User was added successfully!')); |
| 15 | 15 | } |
| 16 | - }else{ |
|
| 16 | + } else{ |
|
| 17 | 17 | $this->storeErrorMessage(_('User name or expiry parameters are missing!')); |
| 18 | 18 | } |
| 19 | 19 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param string $commandToken |
| 24 | 24 | * @param SilverbulletContext $context |
| 25 | 25 | */ |
| 26 | - public function __construct($commandToken, $context){ |
|
| 26 | + public function __construct($commandToken, $context) { |
|
| 27 | 27 | parent::__construct($commandToken, $context); |
| 28 | 28 | $this->context = $context; |
| 29 | 29 | } |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | * {@inheritDoc} |
| 34 | 34 | * @see \web\lib\admin\http\AbstractCommand::execute() |
| 35 | 35 | */ |
| 36 | - public function execute(){ |
|
| 37 | - if(isset($_POST[self::PARAM_NAME]) && isset($_POST[self::PARAM_EXPIRY])){ |
|
| 36 | + public function execute() { |
|
| 37 | + if (isset($_POST[self::PARAM_NAME]) && isset($_POST[self::PARAM_EXPIRY])) { |
|
| 38 | 38 | $name = $this->parseString(filter_input(INPUT_POST, self::PARAM_NAME, FILTER_SANITIZE_STRING)); |
| 39 | 39 | $expiry = $this->parseString($_POST[self::PARAM_EXPIRY]); |
| 40 | 40 | $user = $this->context->createUser($name, $expiry, $this); |
| 41 | - if(!empty($user->getIdentifier())){ |
|
| 41 | + if (!empty($user->getIdentifier())) { |
|
| 42 | 42 | $this->storeInfoMessage(_('User was added successfully!')); |
| 43 | 43 | } |
| 44 | - }else{ |
|
| 44 | + } else { |
|
| 45 | 45 | $this->storeErrorMessage(_('User name or expiry parameters are missing!')); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if(count($this->row) > 0){ |
| 152 | 152 | if(isset($this->row[self::ID])){ |
| 153 | 153 | $result = $this->executeUpdateQuery(); |
| 154 | - }else{ |
|
| 154 | + } else{ |
|
| 155 | 155 | $result = $this->executeInsertQuery(); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -170,8 +170,12 @@ discard block |
||
| 170 | 170 | $types = ''; |
| 171 | 171 | $arguments = array(); |
| 172 | 172 | foreach ($this->row as $key => $attribute) { |
| 173 | - if($keyString != "(") $keyString .= " ,"; |
|
| 174 | - if($valueString != "(") $valueString .= " ,"; |
|
| 173 | + if($keyString != "(") { |
|
| 174 | + $keyString .= " ,"; |
|
| 175 | + } |
|
| 176 | + if($valueString != "(") { |
|
| 177 | + $valueString .= " ,"; |
|
| 178 | + } |
|
| 175 | 179 | $keyString .= "`" . $key . "`"; |
| 176 | 180 | $valueString .= "?"; |
| 177 | 181 | $types .= $attribute->getType(); |
@@ -200,8 +204,11 @@ discard block |
||
| 200 | 204 | $types = ''; |
| 201 | 205 | $arguments = array(); |
| 202 | 206 | foreach ($this->row as $key => $attribute) { |
| 203 | - if(!empty($updateString)) $updateString .= " ,"; |
|
| 204 | - else $updateString .=" SET "; |
|
| 207 | + if(!empty($updateString)) { |
|
| 208 | + $updateString .= " ,"; |
|
| 209 | + } else { |
|
| 210 | + $updateString .=" SET "; |
|
| 211 | + } |
|
| 205 | 212 | $updateString .= "`" . $key . "`=?"; |
| 206 | 213 | $types .= $attribute->getType(); |
| 207 | 214 | $arguments [] = $attribute->value; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param string $table |
| 57 | 57 | * @param string $databaseType |
| 58 | 58 | */ |
| 59 | - public function __construct($table, $databaseType = 'INST'){ |
|
| 59 | + public function __construct($table, $databaseType = 'INST') { |
|
| 60 | 60 | $this->table = $table; |
| 61 | 61 | $this->setAttributeType(self::ID, Attribute::TYPE_INTEGER); |
| 62 | 62 | $this->databaseHandle = \core\DBConnection::handle($databaseType); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param string $key |
| 68 | 68 | * @param string $type |
| 69 | 69 | */ |
| 70 | - protected function setAttributeType($key, $type){ |
|
| 70 | + protected function setAttributeType($key, $type) { |
|
| 71 | 71 | $this->types[$key] = $type; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param string $key |
| 77 | 77 | * @return string |
| 78 | 78 | */ |
| 79 | - protected function getAttributeType($key){ |
|
| 79 | + protected function getAttributeType($key) { |
|
| 80 | 80 | return isset($this->types[$key]) ? $this->types[$key] : Attribute::TYPE_STRING; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param string $key |
| 87 | 87 | * @return string |
| 88 | 88 | */ |
| 89 | - public function get($key){ |
|
| 89 | + public function get($key) { |
|
| 90 | 90 | return isset($this->row[$key]) ? $this->row[$key]->value : ""; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $key |
| 96 | 96 | * @return NULL|\web\lib\admin\domain\Attribute |
| 97 | 97 | */ |
| 98 | - public function getAttribute($key){ |
|
| 98 | + public function getAttribute($key) { |
|
| 99 | 99 | return isset($this->row[$key]) ? $this->row[$key] : new Attribute('', ''); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param string $key |
| 106 | 106 | * @param mixed $value |
| 107 | 107 | */ |
| 108 | - protected function set($key, $value){ |
|
| 108 | + protected function set($key, $value) { |
|
| 109 | 109 | $attribute = new Attribute($key, $value, $this->getAttributeType($key)); |
| 110 | 110 | $this->row[$key] = $attribute; |
| 111 | 111 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param array $row |
| 116 | 116 | */ |
| 117 | - public function setRow($row){ |
|
| 117 | + public function setRow($row) { |
|
| 118 | 118 | $this->clear(); |
| 119 | - foreach ($row as $key => $value){ |
|
| 119 | + foreach ($row as $key => $value) { |
|
| 120 | 120 | $this->set($key, $value); |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | /** |
| 125 | 125 | * |
| 126 | 126 | */ |
| 127 | - public function clear(){ |
|
| 127 | + public function clear() { |
|
| 128 | 128 | $this->row = array(); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function getIdentifier(){ |
|
| 135 | + public function getIdentifier() { |
|
| 136 | 136 | return $this->get(self::ID); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | * {@inheritDoc} |
| 142 | 142 | * @see \web\lib\admin\domain\PersistentInterface::save() |
| 143 | 143 | */ |
| 144 | - public function save(){ |
|
| 144 | + public function save() { |
|
| 145 | 145 | $result = false; |
| 146 | - if(count($this->row) > 0){ |
|
| 147 | - if(isset($this->row[self::ID])){ |
|
| 146 | + if (count($this->row) > 0) { |
|
| 147 | + if (isset($this->row[self::ID])) { |
|
| 148 | 148 | $result = $this->executeUpdateQuery(); |
| 149 | - }else{ |
|
| 149 | + } else { |
|
| 150 | 150 | $result = $this->executeInsertQuery(); |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return boolean|mixed |
| 159 | 159 | */ |
| 160 | - private function executeInsertQuery(){ |
|
| 160 | + private function executeInsertQuery() { |
|
| 161 | 161 | $result = false; |
| 162 | 162 | $query = sprintf("INSERT INTO `%s`", $this->table); |
| 163 | 163 | $keyString = "("; |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | $types = ''; |
| 166 | 166 | $arguments = array(); |
| 167 | 167 | foreach ($this->row as $key => $attribute) { |
| 168 | - if($keyString != "(") $keyString .= " ,"; |
|
| 169 | - if($valueString != "(") $valueString .= " ,"; |
|
| 168 | + if ($keyString != "(") $keyString .= " ,"; |
|
| 169 | + if ($valueString != "(") $valueString .= " ,"; |
|
| 170 | 170 | $keyString .= "`" . $key . "`"; |
| 171 | 171 | $valueString .= "?"; |
| 172 | 172 | $types .= $attribute->getType(); |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | $keyString .= ")"; |
| 176 | 176 | $valueString .= ")"; |
| 177 | 177 | $isValid = $this->validate(); |
| 178 | - if($isValid && $keyString != "()"){ |
|
| 179 | - $query .= " " .$keyString . " VALUES " . $valueString; |
|
| 178 | + if ($isValid && $keyString != "()") { |
|
| 179 | + $query .= " " . $keyString . " VALUES " . $valueString; |
|
| 180 | 180 | $result = $this->databaseHandle->exec($query, $types, ...$arguments); |
| 181 | - if($result){ |
|
| 181 | + if ($result) { |
|
| 182 | 182 | $this->set(self::ID, $this->databaseHandle->lastID()); |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -189,21 +189,21 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return boolean|mixed |
| 191 | 191 | */ |
| 192 | - private function executeUpdateQuery(){ |
|
| 192 | + private function executeUpdateQuery() { |
|
| 193 | 193 | $result = false; |
| 194 | 194 | $query = sprintf("UPDATE `%s`", $this->table); |
| 195 | 195 | $updateString = ""; |
| 196 | 196 | $types = ''; |
| 197 | 197 | $arguments = array(); |
| 198 | 198 | foreach ($this->row as $key => $attribute) { |
| 199 | - if(!empty($updateString)) $updateString .= " ,"; |
|
| 200 | - else $updateString .=" SET "; |
|
| 199 | + if (!empty($updateString)) $updateString .= " ,"; |
|
| 200 | + else $updateString .= " SET "; |
|
| 201 | 201 | $updateString .= "`" . $key . "`=?"; |
| 202 | 202 | $types .= $attribute->getType(); |
| 203 | 203 | $arguments [] = $attribute->value; |
| 204 | 204 | } |
| 205 | - if(!empty($updateString)){ |
|
| 206 | - $query .= " " .$updateString . " WHERE `" .self::ID. "`=?"; |
|
| 205 | + if (!empty($updateString)) { |
|
| 206 | + $query .= " " . $updateString . " WHERE `" . self::ID . "`=?"; |
|
| 207 | 207 | $id = $this->getAttribute(self::ID); |
| 208 | 208 | $types .= $id->getType(); |
| 209 | 209 | $arguments [] = $id->value; |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | * {@inheritDoc} |
| 217 | 217 | * @see \web\lib\admin\domain\PersistentInterface::load() |
| 218 | 218 | */ |
| 219 | - public function load($searchAttribute = null){ |
|
| 219 | + public function load($searchAttribute = null) { |
|
| 220 | 220 | $state = false; |
| 221 | 221 | $id = $this->getAttribute(self::ID); |
| 222 | 222 | $query = sprintf("SELECT * FROM `%s` WHERE `%s` =?", $this->table, self::ID); |
| 223 | 223 | $value = $id->value; |
| 224 | 224 | $result = $this->databaseHandle->exec($query, $id->getType(), $value); |
| 225 | - if(mysqli_num_rows($result)>0){ |
|
| 225 | + if (mysqli_num_rows($result) > 0) { |
|
| 226 | 226 | $this->setRow(mysqli_fetch_assoc($result)); |
| 227 | 227 | $state = true; |
| 228 | 228 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * {@inheritDoc} |
| 235 | 235 | * @see \web\lib\admin\domain\PersistentInterface::delete() |
| 236 | 236 | */ |
| 237 | - public function delete(){ |
|
| 237 | + public function delete() { |
|
| 238 | 238 | $id = $this->getAttribute(self::ID); |
| 239 | 239 | $query = sprintf("DELETE FROM `%s` WHERE `%s`=?", $this->table, self::ID); |
| 240 | 240 | $type = $id->getType(); |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | * |
| 64 | 64 | * @return string |
| 65 | 65 | */ |
| 66 | - public function getType(){ |
|
| 66 | + public function getType() { |
|
| 67 | 67 | return $this->type; |
| 68 | 68 | } |
| 69 | 69 | |