-
Notifications
You must be signed in to change notification settings - Fork 16
/
XBRL-USGAAP-Package.php
144 lines (129 loc) · 4.58 KB
/
XBRL-USGAAP-Package.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* XBRL IFRS Taxonomy Package handler
*
* @author Bill Seddon
* @version 0.9
* @Copyright (C) 2018 Lyquidity Solutions Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Implements functions to read an IFRS taxonomy package
*/
class XBRL_USGAAP_Package extends XBRL_TaxonomyPackage
{
/**
* Notes about using this package instance
* @var string
*/
const notes = <<<EOT
Uses the path of the entry point in the taxonomyPackage.xml file to determine the path to use in the cache.
This should be the same as the value used in the schemaRef element in the instance document.
The 'identifier' value in the taxonomyPackage.xml file appears to be the namespace of the taxonomy.\n\n
The static array '\$defaultEntryPoints' will need to be updated each time there is a new taxonomy release
to add a new default entry point.\n\n
EOT;
/**
* This will need to be updated when a new taxonomy is released
* @var array Indexed by publication date
*/
private static $defaultEntryPoints = array(
'2016-01-31' => 'http://xbrl.fasb.org/us-gaap/2016/entire/us-gaap-entryPoint-all-2016-01-31.xsd',
'2017-01-31' => 'http://xbrl.fasb.org/us-gaap/2017/entire/us-gaap-entryPoint-all-2017-01-31.xsd',
'2018-01-31' => 'http://xbrl.fasb.org/us-gaap/2018/entire/us-gaap-entryPoint-all-2018-01-31.xsd',
'2019-01-31' => 'http://xbrl.fasb.org/us-gaap/2019/entire/us-gaap-entryPoint-all-2019-01-31.xsd',
'2020-01-31' => 'http://xbrl.fasb.org/us-gaap/2020/entire/us-gaap-entryPoint-all-2020-01-31.xsd'
);
/**
*
* @param \ZipArchive $zipArchive
*/
public function __construct( $zipArchive )
{
$this->skipEntryPoints = array(
'http://xbrl.fasb.org/us-gaap/2017/entire/us-gaap-entryPoint-all-2017-01-31.xsd'
);
parent::__construct( $zipArchive );
}
/**
* Returns true if the zip file represents a package that meets the taxonomy package specification
* {@inheritDoc}
* @see XBRL_Package::isPackage()
*/
public function isPackage()
{
if ( ! parent::isPackage() ) return false;
// If it is a package then is an IFRS taxonomy package?
// A US-GAAP package is characterised by having one or more of the
// package entry points be the entry points in the XBRL_US_GAAP_2015 entry point list
// and no instance document.
// Check the entry points first because they are already in an array.
foreach ( $this->getSchemaEntryPoints() as $entryPoint )
{
if ( XBRL::startsWith( $entryPoint, "http://xbrl.fasb.org/us-gaap/" ) ) return true;
}
return false;
}
/**
* Returns false
* @param string $schemaFile
* @return bool
* @final
*/
public function isExtensionTaxonomy( $schemaFile = null )
{
return false;
}
/**
* Workout which file is the schema file
* @return void
* @throws "tpe:schemaFileNotFound"
*/
protected function determineSchemaFile()
{
if ( ! is_null( $this->schemaFile ) ) return;
$schemaFilesList = $this->getSchemaEntryPoints();
if ( count( $schemaFilesList ) == 0 )
{
throw XBRL_TaxonomyPackageException::withError( "tpe:schemaFileNotFound", "The package does not contain a schema (.xsd) file" );
}
foreach ( $schemaFilesList as $schemaFile )
{
$actualUri = $this->getActualUri( $schemaFile );
$content = $this->getFile( $actualUri );
if ( $content )
{
$schemaNamespace = $this->getTargetNamespace( $schemaFile, $content );
$this->setUrlMap( $schemaNamespace, $schemaFile );
if ( isset( XBRL_USGAAP_Package::$defaultEntryPoints[ $this->publicationDate ] ) &&
XBRL_USGAAP_Package::$defaultEntryPoints[ $this->publicationDate ] == $schemaFile )
{
$this->schemaNamespace = $schemaNamespace;
$this->schemaFile = $schemaFile;
}
}
}
}
/**
* Returns the name of the XBRL class that supports S GAAP pckage contents
* {@inheritDoc}
* @see XBRL_Package::getXBRLClassname()
*/
public function getXBRLClassname()
{
return "XBRL_US_GAAP_2015";
}
}