Fix psr2 CS

This commit is contained in:
Michael RICOIS 2016-11-24 13:55:22 +01:00
parent 6356f3566c
commit 2598a463b7

View File

@ -51,8 +51,7 @@ class Metier_Liens_Base
{
if ($conn === null) {
$this->conn = Zend_Registry::get('doctrine');
}
else {
} else {
$this->conn = $conn;
}
}
@ -65,7 +64,7 @@ class Metier_Liens_Base
public function setId($id, $type = 'ref')
{
// Get Id
if ( $type == 'siren' ) {
if ($type == 'siren') {
$this->siren = $id;
try {
$sql = "SELECT * FROM jo.liensRef WHERE siren = :id AND dateSuppr = 0";
@ -76,12 +75,10 @@ class Metier_Liens_Base
$result = $stmt->fetch(\PDO::FETCH_OBJ);
$this->idRef = $result->id;
}
}
catch (\Doctrine\DBAL\DBALException $e) {
} catch (\Doctrine\DBAL\DBALException $e) {
throw new Exception(__METHOD__ . ': ' . $e->getMessage());
}
}
else {
} else {
$this->idRef = $id;
}
}
@ -94,13 +91,13 @@ class Metier_Liens_Base
*/
public function getActionnaires($id = null, $actif = null)
{
if ( null === $id ) {
if (null === $id) {
$id = $this->idRef;
}
$liens = array();
if ( null === $id ) {
if (null === $id) {
return $liens;
}
@ -121,8 +118,8 @@ class Metier_Liens_Base
->orderBy('l.PDetention', 'DESC');
// Actif / Inactif
if ( null !== $actif ) {
if ( false === $actif ) {
if (null !== $actif) {
if (false === $actif) {
$qb->andWhere('l.actif = 0');
} else {
$qb->andWhere('l.actif = 1');
@ -131,10 +128,9 @@ class Metier_Liens_Base
// Don't display deleted - anomaly
$qb->andWhere("l.dateSuppr = '0000-00-00 00:00:00'");
$stmt = $qb->execute();
$liens = $stmt->fetchAll(\PDO::FETCH_OBJ);
}
catch (\Doctrine\DBAL\DBALException $e) {
$stmt = $qb->execute();
$liens = $stmt->fetchAll(\PDO::FETCH_OBJ);
} catch (\Doctrine\DBAL\DBALException $e) {
throw new Exception(__METHOD__ . ': ' . $e->getMessage());
}
@ -149,11 +145,11 @@ class Metier_Liens_Base
*/
public function getParticipations($id = null, $actif = null)
{
if ( null === $id ) {
if (null === $id) {
$id = $this->idRef;
}
if ( false === $actif ) {
if (false === $actif) {
$actif = 0;
} else {
$actif = 1;
@ -161,7 +157,7 @@ class Metier_Liens_Base
$liens = array();
if ( null === $id ) {
if (null === $id) {
return $liens;
}
@ -182,8 +178,8 @@ class Metier_Liens_Base
->orderBy('l.PDetention', 'DESC');
// Actif / Inactif
if ( null !== $actif ) {
if ( false === $actif ) {
if (null !== $actif) {
if (false === $actif) {
$qb->andWhere('l.actif = 0');
} else {
$qb->andWhere('l.actif = 1');
@ -194,8 +190,7 @@ class Metier_Liens_Base
$qb->andWhere("l.dateSuppr = '0000-00-00 00:00:00'");
$stmt = $qb->execute();
$liens = $stmt->fetchAll(\PDO::FETCH_OBJ);
}
catch (\Doctrine\DBAL\DBALException $e) {
} catch (\Doctrine\DBAL\DBALException $e) {
throw new Exception(__METHOD__ . ': ' . $e->getMessage());
}
@ -215,8 +210,7 @@ class Metier_Liens_Base
$stmt->bindValue('id', $this->idRef);
$result = $stmt->fetch(\PDO::FETCH_OBJ);
$siren = $result->siren;
}
else {
} else {
$siren = $this->siren;
}
@ -232,10 +226,9 @@ class Metier_Liens_Base
->andWhere('dirSiren = :siren')->setParameter('siren', $siren);
// Actif / Inactif
if (null !== $actif) {
if ( false === $actif ) {
if (false === $actif) {
$qb->andWhere('actif = 0');
}
else {
} else {
$qb->andWhere('actif = 1');
}
}
@ -261,7 +254,7 @@ class Metier_Liens_Base
*/
public function getHead($id = null, $detention = 0)
{
if ( null === $id ) {
if (null === $id) {
$id = $this->idRef;
}
@ -272,32 +265,32 @@ class Metier_Liens_Base
$liens = $this->getActionnaires($id, true);
//Find the following up entity
if ( count($liens)>0 ) {
foreach ( $liens as $item ) {
if (count($liens)>0) {
foreach ($liens as $item) {
//Don't through again and again
if ( in_array($item->idAct, $this->findId) ) {
if (in_array($item->idAct, $this->findId)) {
return $item->idAct;
} elseif ( $this->stopAtFirstIsin === true && !empty($item->isin)) {
} elseif ($this->stopAtFirstIsin === true && !empty($item->isin)) {
break;
}
//Remove physical person
elseif ( $item->PpPm == 'PP' && $this->stopAtPP ) {
elseif ($item->PpPm == 'PP' && $this->stopAtPP) {
continue;
}
//Same id
elseif ( $item->idAct == $id ) {
elseif ($item->idAct == $id) {
return $id;
}
//PDetention>50
elseif ( $item->PDetention > 50 && $item->idAct > 1000 ) {
elseif ($item->PDetention > 50 && $item->idAct > 1000) {
return $this->getHead($item->idAct, $detention);
}
//MajMin=+
elseif ( $item->PDetention > $detention && $item->MajMin == '+' && $item->idAct > 1000 ) {
elseif ($item->PDetention > $detention && $item->MajMin == '+' && $item->idAct > 1000) {
return $this->getHead($item->idAct, $detention);
}
//--
elseif ( $item->PDetention > $detention && $item->idAct > 1000 ) {
elseif ($item->PDetention > $detention && $item->idAct > 1000) {
return $this->getHead($item->idAct, $detention);
}
}
@ -313,7 +306,7 @@ class Metier_Liens_Base
*/
public function getIdentity($id = null)
{
if ( null === $id ) {
if (null === $id) {
$id = $this->idRef;
}
@ -338,15 +331,15 @@ class Metier_Liens_Base
{
//Get identity to stop at isin
$itemWithIsin = null;
if ( $this->stopAtFirstIsin === true ) {
if ($this->stopAtFirstIsin === true) {
$id = $this->idRef;
$identity = $this->getIdentity($this->idRef);
if ( !empty($identity->isin) ) {
if (!empty($identity->isin)) {
$itemWithIsin = true;
}
}
if ( $itemWithIsin !== true ) {
if ($itemWithIsin !== true) {
//Récupération de la maison mère
$id = $this->getHead(null, 50);
//Informations de la maison mère
@ -357,21 +350,21 @@ class Metier_Liens_Base
$this->findId[] = $identity->id;
$nom = $identity->RS;
if ( $identity->nom != '') {
if ($identity->nom != '') {
$nom = $identity->civilite.' '.$identity->nom.' '.$identity->prenom;
}
if ( $this->country === null ) {
if ($this->country === null) {
$this->country = $this->getCountry();
}
$pays = $identity->adresse_pays;
if ( array_key_exists($identity->adresse_pays, $this->country) ) {
if (array_key_exists($identity->adresse_pays, $this->country)) {
$pays = $this->country[$identity->adresse_pays];
}
//Retour
$tabRet = array (
$tabRet = array(
'id' => $identity->id,
'name' => $nom,
'siren' => str_pad($identity->siren, 9, '0', STR_PAD_LEFT),
@ -391,20 +384,22 @@ class Metier_Liens_Base
* @param int $nbNiveaux
* @return array
*/
public function getTreeRecursive( $id, $pctMin=33, $niveau=0, $nbNiveaux=10 )
public function getTreeRecursive($id, $pctMin=33, $niveau=0, $nbNiveaux=10)
{
if ( $niveau > $nbNiveaux ) return array();
if ($niveau > $nbNiveaux) {
return array();
}
$niveau++;
$tabRet = array();
$participations = $this->getParticipations($id, true);
if ( count($participations)>0 ) {
foreach ( $participations as $item ) {
if ( $item->PDetention > $pctMin ) {
if (count($participations)>0) {
foreach ($participations as $item) {
if ($item->PDetention > $pctMin) {
$identity = $this->getIdentity($item->idPar);
$nom = $identity->RS;
if ( $identity->nom != '') {
if ($identity->nom != '') {
$nom = $identity->civilite.' '.$identity->nom.' '.$identity->prenom;
}
@ -413,11 +408,11 @@ class Metier_Liens_Base
}
$pays = $identity->adresse_pays;
if ( array_key_exists($identity->adresse_pays, $this->country) ) {
if (array_key_exists($identity->adresse_pays, $this->country)) {
$pays = $this->country[$identity->adresse_pays];
}
$data = array (
$data = array(
'id' => $identity->id,
'name' => $nom,
'siren' => str_pad($identity->siren, 9, '0', STR_PAD_LEFT),
@ -426,7 +421,7 @@ class Metier_Liens_Base
'children' => array(),
);
//Pour éviter d'avoir des boucles infinis
if ( !in_array($identity->id, $this->findId) ){
if (!in_array($identity->id, $this->findId)) {
$this->findId[] = $identity->id;
$data['children'] = $this->getTreeRecursive($identity->id, $pctMin, $niveau, $nbNiveaux);
}
@ -450,7 +445,7 @@ class Metier_Liens_Base
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$output = array();
foreach ( $result as $item ) {
foreach ($result as $item) {
$output[] = $item->isin;
}
@ -465,7 +460,7 @@ class Metier_Liens_Base
public function getGroupeCAC40($pctMin = 50)
{
$listeIsin = $this->getCAC40();
$isin = "'".implode("','",$listeIsin)."'";
$isin = "'".implode("','", $listeIsin)."'";
$this->findId = array();
@ -475,7 +470,7 @@ class Metier_Liens_Base
$output = array();
if ($stmt->rowCount() > 0) {
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
foreach ( $result as $item ) {
foreach ($result as $item) {
$output = $output + $this->getListeGroupeCAC40($item->id, $pctMin);
}
}
@ -489,24 +484,23 @@ class Metier_Liens_Base
* @param number $pctMin
* @return array
*/
public function getListeGroupeCAC40($id, $pctMin=50 )
public function getListeGroupeCAC40($id, $pctMin=50)
{
$participations = $this->getParticipations($id, true);
$output = array();
if ( count($participations)>0 ) {
foreach ( $participations as $item ) {
if ( $item->PDetention > $pctMin ) {
if (count($participations)>0) {
foreach ($participations as $item) {
if ($item->PDetention > $pctMin) {
$identity = $this->getIdentity($item->idPar);
if ( intval($identity->siren)!=0 ) {
if (intval($identity->siren)!=0) {
$output[] = $identity->siren;
}
if ( !in_array($identity->id, $this->findId) ){
if (!in_array($identity->id, $this->findId)) {
$this->findId[] = $identity->id;
$output = $output + $this->getListeGroupeCAC40($identity->id, $pctMin);
}
}
}
}
@ -521,12 +515,12 @@ class Metier_Liens_Base
public function isInGroupeCAC40($pctMin = 50)
{
//Si pas d'actionnaires => false
if ( count($this->getActionnaires()) == 0 ) {
if (count($this->getActionnaires()) == 0) {
return false;
}
$listeInGroupeCAC40 = $this->getGroupeCAC40($pctMin);
if ( in_array($this->siren, $listeInGroupeCAC40) ) {
if (in_array($this->siren, $listeInGroupeCAC40)) {
return true;
}
@ -543,7 +537,7 @@ class Metier_Liens_Base
$stmt->execute();
if ($stmt->rowCount() > 0) {
$data = array();
foreach($rows as $item) {
foreach ($rows as $item) {
$data[$item->codPays3] = $item->libPays;
}
return $data;
@ -551,4 +545,4 @@ class Metier_Liens_Base
return false;
}
}
}