Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* +----------------------------------------------------------------------+ | (c) Co..

Decoded Output download

<?php
/*
+----------------------------------------------------------------------+
| (c) Copyright IBM Corporation 2005.                                  |
| All Rights Reserved.                                                 |
+----------------------------------------------------------------------+
|                                                                      |
| Licensed under the Apache License, Version 2.0 (the "License"); you  |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at                                      |
| http://www.apache.org/licenses/LICENSE-2.0                           |
|                                                                      |
| Unless required by applicable law or agreed to in writing, software  |
| distributed under the License is distributed on an "AS IS" BASIS,    |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
| implied. See the License for the specific language governing         |
| permissions and limitations under the License.                       |
+----------------------------------------------------------------------+
| Author: Matthew Peters                                               |
+----------------------------------------------------------------------+
$Id: PrimaryKey.php 220738 2006-09-28 19:25:00Z cem $
*/

/**
* SDO_DAS_Relational_PrimaryKey encapsulates all the information about a table's primary key
*
* 1 it has a column name
* 2 the name is a string
* 3 it may be autogenerated
*/

class SDO_DAS_Relational_PrimaryKey {
    private $column_name;
    private $autogenerated = false;

    public function __construct($pk_metadata, $table_name)
    {

        /*
        * Check PK metadata is an array
        */
        if (gettype($pk_metadata) != 'array') {
            $msg = "The metadata for table ".$table_name." specified metadata for a primary key that was not an array.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * Check PK metadata specifies a name
        */
        if (array_key_exists('name', $pk_metadata)) {
            $this->column_name = $pk_metadata['name'];
        } else {
            $msg = "The metadata for table ".$table_name." defined a primary key but with no name.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * Check name is a string
        */
        if (gettype($this->column_name) != 'string') {
            $msg = "The metadata for table ".$table_name." defined a primary key with a name that is not a string.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * If PK metadata specifies autogenerate, assign it, then ensure it is a boolean
        */
        if (array_key_exists('autogenerated', $pk_metadata)) {
            $this->autogenerated = $pk_metadata['autogenerated'];
        }

        if (gettype($this->autogenerated) != 'boolean') {
            $msg = "The metadata for table ".$table_name." defined a primary key with autogenerated set but not to a boolean.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * Check we have only valid keys in the metadata
        */
        $valid_keys = array('name', 'autogenerated');
        $supplied_keys = array_keys($pk_metadata);

        if (count(array_diff($supplied_keys, $valid_keys))) {
            throw new SDO_DAS_Relational_Exception('The metadata for table '.$table_name.' contained a PK setting with an invalid key. Only valid keys are name, autogenerated.');
        }
    }

    public function getColumnName ()
    {
        return $this->column_name;
    }

    public function getAutoGenerated ()
    {
        return $this->autogenerated;
    }

}

?>

Did this file decode correctly?

Original Code

<?php
/*
+----------------------------------------------------------------------+
| (c) Copyright IBM Corporation 2005.                                  |
| All Rights Reserved.                                                 |
+----------------------------------------------------------------------+
|                                                                      |
| Licensed under the Apache License, Version 2.0 (the "License"); you  |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at                                      |
| http://www.apache.org/licenses/LICENSE-2.0                           |
|                                                                      |
| Unless required by applicable law or agreed to in writing, software  |
| distributed under the License is distributed on an "AS IS" BASIS,    |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
| implied. See the License for the specific language governing         |
| permissions and limitations under the License.                       |
+----------------------------------------------------------------------+
| Author: Matthew Peters                                               |
+----------------------------------------------------------------------+
$Id: PrimaryKey.php 220738 2006-09-28 19:25:00Z cem $
*/

/**
* SDO_DAS_Relational_PrimaryKey encapsulates all the information about a table's primary key
*
* 1 it has a column name
* 2 the name is a string
* 3 it may be autogenerated
*/

class SDO_DAS_Relational_PrimaryKey {
    private $column_name;
    private $autogenerated = false;

    public function __construct($pk_metadata, $table_name)
    {

        /*
        * Check PK metadata is an array
        */
        if (gettype($pk_metadata) != 'array') {
            $msg = "The metadata for table ".$table_name." specified metadata for a primary key that was not an array.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * Check PK metadata specifies a name
        */
        if (array_key_exists('name', $pk_metadata)) {
            $this->column_name = $pk_metadata['name'];
        } else {
            $msg = "The metadata for table ".$table_name." defined a primary key but with no name.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * Check name is a string
        */
        if (gettype($this->column_name) != 'string') {
            $msg = "The metadata for table ".$table_name." defined a primary key with a name that is not a string.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * If PK metadata specifies autogenerate, assign it, then ensure it is a boolean
        */
        if (array_key_exists('autogenerated', $pk_metadata)) {
            $this->autogenerated = $pk_metadata['autogenerated'];
        }

        if (gettype($this->autogenerated) != 'boolean') {
            $msg = "The metadata for table ".$table_name." defined a primary key with autogenerated set but not to a boolean.";
            throw new SDO_DAS_Relational_Exception($msg);
        }

        /*
        * Check we have only valid keys in the metadata
        */
        $valid_keys = array('name', 'autogenerated');
        $supplied_keys = array_keys($pk_metadata);

        if (count(array_diff($supplied_keys, $valid_keys))) {
            throw new SDO_DAS_Relational_Exception('The metadata for table '.$table_name.' contained a PK setting with an invalid key. Only valid keys are name, autogenerated.');
        }
    }

    public function getColumnName ()
    {
        return $this->column_name;
    }

    public function getAutoGenerated ()
    {
        return $this->autogenerated;
    }

}

?>

Function Calls

None

Variables

None

Stats

MD5 c6a6dfb8ec820b9d78eb0a47fae6df1f
Eval Count 0
Decode Time 118 ms